JakobGM / patito

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

Fix test failure due to polars 1.2 #91

Closed thomasaarholt closed 3 months ago

thomasaarholt commented 3 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.