polars.Expr.map.len#

Expr.map.len() → Expr[source]#

Get the number of entries of every map.

engine:In MemoryStreamingDistributed
Returns:
Expr

Expression of data type UInt32.

Examples

>>> df = pl.DataFrame(
...     {
...         "m": pl.Series(
...             [{"a": 1, "b": 2}, {}, None], dtype=pl.Map(pl.String, pl.Int64)
...         )
...     }
... )
>>> df.select(pl.col("m").map.len())
shape: (3, 1)
┌──────┐
│ m    │
│ ---  │
│ u32  │
╞══════╡
│ 2    │
│ 0    │
│ null │
└──────┘