polars.Expr.arr.len#

Expr.arr.len() Expr[source]#

Return the number of elements in each array.

Examples

>>> df = pl.DataFrame(
...     data={"a": [[1, 2], [4, 3]]},
...     schema={"a": pl.Array(pl.Int64, 2)},
... )
>>> df.select(pl.col("a").arr.len())
shape: (2, 1)
┌─────┐
│ a   │
│ --- │
│ u32 │
╞═════╡
│ 2   │
│ 2   │
└─────┘