polars.Series.arr.agg#

Series.arr.agg(expr: Expr) Series[source]#

Run any polars aggregation expression against the arrays’ elements.

Parameters:
expr

Expression to run. Note that you can select an element with pl.element().

Examples

>>> s = pl.Series(
...     "a", [[1, None], [42, 13], [None, None]], pl.Array(pl.Int64, 2)
... )
>>> s.arr.agg(pl.element().null_count())
shape: (3,)
Series: 'a' [u32]
[
    1
    0
    2
]
>>> s.arr.agg(pl.element().drop_nulls())
shape: (3,)
Series: 'a' [list[i64]]
[
    [1]
    [42, 13]
    []
]