polars.Expr.arr.any#

Expr.arr.any(*, ignore_nulls: bool = True) Expr[source]#

Evaluate whether any boolean value is true for every subarray.

Parameters:
ignore_nulls
  • If set to True (default), null values are ignored. If there are no non-null values, the output is False.

  • If set to False, Kleene logic is used to deal with nulls: if the column contains any null values and no True values, the output is null.

Examples

>>> df = pl.DataFrame(
...     data={
...         "a": [
...             [True, True],
...             [False, True],
...             [False, False],
...             [None, None],
...             None,
...         ]
...     },
...     schema={"a": pl.Array(pl.Boolean, 2)},
... )
>>> df.with_columns(any=pl.col("a").arr.any())
shape: (5, 2)
┌────────────────┬───────┐
│ a              ┆ any   │
│ ---            ┆ ---   │
│ array[bool, 2] ┆ bool  │
╞════════════════╪═══════╡
│ [true, true]   ┆ true  │
│ [false, true]  ┆ true  │
│ [false, false] ┆ false │
│ [null, null]   ┆ false │
│ null           ┆ null  │
└────────────────┴───────┘