polars.Expr.arr.explode#
- Expr.arr.explode(*, empty_as_null: bool = True, keep_nulls: bool = True) Expr[source]#
Returns a column with a separate row for every array element.
- Parameters:
- empty_as_null
Explode an empty array into a
null.- keep_nulls
Explode a
nullarray into anull.
- Returns:
- Expr
Expression with the data type of the array elements.
Examples
>>> df = pl.DataFrame( ... {"a": [[1, 2, 3], [4, 5, 6]]}, schema={"a": pl.Array(pl.Int64, 3)} ... ) >>> df.select(pl.col("a").arr.explode()) shape: (6, 1) ┌─────┐ │ a │ │ --- │ │ i64 │ ╞═════╡ │ 1 │ │ 2 │ │ 3 │ │ 4 │ │ 5 │ │ 6 │ └─────┘