polars.Expr.all#

Expr.all(drop_nulls: bool = True) Self[source]#

Check if all boolean values in a Boolean column are True.

This method is an expression - not to be confused with polars.all() which is a function to select all columns.

Parameters:
drop_nulls

If False, return None if there are any nulls.

Returns:
Expr

Expression of data type Boolean.

Examples

>>> df = pl.DataFrame(
...     {"TT": [True, True], "TF": [True, False], "FF": [False, False]}
... )
>>> df.select(pl.col("*").all())
shape: (1, 3)
┌──────┬───────┬───────┐
│ TT   ┆ TF    ┆ FF    │
│ ---  ┆ ---   ┆ ---   │
│ bool ┆ bool  ┆ bool  │
╞══════╪═══════╪═══════╡
│ true ┆ false ┆ false │
└──────┴───────┴───────┘
>>> df = pl.DataFrame(dict(x=[None, False], y=[None, True]))
>>> df.select(pl.col("x").all(True), pl.col("y").all(True))
shape: (1, 2)
┌───────┬───────┐
│ x     ┆ y     │
│ ---   ┆ ---   │
│ bool  ┆ bool  │
╞═══════╪═══════╡
│ false ┆ false │
└───────┴───────┘
>>> df.select(pl.col("x").all(False), pl.col("y").all(False))
shape: (1, 2)
┌──────┬──────┐
│ x    ┆ y    │
│ ---  ┆ ---  │
│ bool ┆ bool │
╞══════╪══════╡
│ null ┆ null │
└──────┴──────┘