JakobGM / patito

A data modelling layer built on top of polars and pydantic
MIT License
307 stars 24 forks source link

Fix test failure due to polars 1.2 #91

Closed thomasaarholt closed 2 months ago

thomasaarholt commented 2 months ago

Fixes a bug and supports new polars behaviour

We were currently dropping rows in struct columns that contained only nulls, potentially dropping values from other columns before validation. Now we use the entire dataframe again when checking each column. We might be able to avoid passing the entire dataframe and just passing series.

Polars 1.2 allows null structs despite filtering them away: pl.DataFrame({"foo":{"a":None}}).filter(pl.col("foo").is_not_null()) still returns rows. We fix this by checking to see if all struct fields are null, and in that case dropping the row.