[Python] Check if all values of Polars DataFrame are True

Discussão em 'Python' iniciado por Stack, Abril 10, 2025.

  1. Stack

    Stack Membro Participativo

    How can I check if all values of a polars DataFrame, containing only boolean columns, are True?
    Example df:

    df = pl.DataFrame({"a": [True, True, None],
    "b": [True, True, True],
    })


    The reason for my question is that sometimes I want to check if all values of a df fulfill a condition, like in the following:

    df = pl.DataFrame({"a": [1, 2, None],
    "b": [4, 5, 6],
    }).select(pl.all() >= 1)


    By the way, I didn't expect that .select(pl.all() >= 1) keeps the null (None) in last row of column "a", maybe that's worth noting.

    Continue reading...

Compartilhe esta Página