Return the number of elements in each sub-array
Description
Return the number of elements in each sub-array
Usage
<Expr>$arr$len()
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(
a = list(c(1, 1, 2), c(2, 3, 4))
)$cast(pl$Array(pl$Int64, 3))
df$with_columns(len = pl$col("a")$arr$len())
#> shape: (2, 2)
#> ┌───────────────┬─────┐
#> │ a ┆ len │
#> │ --- ┆ --- │
#> │ array[i64, 3] ┆ u32 │
#> ╞═══════════════╪═════╡
#> │ [1, 1, 2] ┆ 3 │
#> │ [2, 3, 4] ┆ 3 │
#> └───────────────┴─────┘