[Python] Polars: Addressing "The predicate passed to 'LazyFrame.filter' expanded to multiple...

Discussão em 'Python' iniciado por Stack, Maio 2, 2025.

  1. Stack

    Stack Membro Participativo

    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?

    Continue reading...

Compartilhe esta Página