From Polars 0.16.11 the following filter statement raises an exception with the following error message:
import polars as pl
df = pl.DataFrame({'lag1':[0,1,None],'lag2':[0,None,2]})
df.filter(pl.col('^lag.*$').is_not_null())
ComputeError: The predicate passed to 'LazyFrame.filter' expanded to multiple expressions:
col("lag1").is_not_null().any(),
col("lag2").is_not_null().any(),
This is ambiguous. Try to combine the predicates with the 'all' or `any' expression.
How can I address it to filter rows where any of the lag columns are null?
As @lxlxlx rightfully mentioned, as of today's Polars API, the correct way to evaluate against a predicate containing multiple Boolean expressions is either by using:
pl.all_horizontal() (for bitwise AND horizontally across expressions)pl.any_horizontal() (for bitwise OR horizontally across expressions).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With