polars.Expr.explode#
- Expr.explode() Self [source]#
Explode a list expression.
This means that every item is expanded to a new row.
- Returns:
- Expr
Expression with the data type of the list elements.
See also
Expr.list.explode
Explode a list column.
Expr.str.explode
Explode a string column.
Examples
>>> df = pl.DataFrame( ... { ... "group": ["a", "b"], ... "values": [ ... [1, 2], ... [3, 4], ... ], ... } ... ) >>> df.select(pl.col("values").explode()) shape: (4, 1) ┌────────┐ │ values │ │ --- │ │ i64 │ ╞════════╡ │ 1 │ │ 2 │ │ 3 │ │ 4 │ └────────┘