polars.Expr.str.explode#

Expr.str.explode() Expr[source]#

Returns a column with a separate row for every string character.

Deprecated since version 0.20.31: Use .str.split("").explode() instead. Note that empty strings will result in null instead of being preserved. To get the exact same behavior, split first and then use when/then/otherwise to handle the empty list before exploding.

Returns:
Expr

Expression of data type String.

Examples

>>> df = pl.DataFrame({"a": ["foo", "bar"]})
>>> df.select(pl.col("a").str.explode())
shape: (6, 1)
┌─────┐
│ a   │
│ --- │
│ str │
╞═════╡
│ f   │
│ o   │
│ o   │
│ b   │
│ a   │
│ r   │
└─────┘