polars.internals.expr.ExprStringNameSpace.split¶
- ExprStringNameSpace.split(by: str, inclusive: bool = False) polars.internals.expr.Expr ¶
Split the string by a substring. The return type will by of type List<Utf8>
- Parameters
- by
substring
- inclusive
Include the split character/string in the results
Examples
>>> df = pl.DataFrame({"s": ["foo bar", "foo-bar", "foo bar baz"]}) >>> df.select(pl.col("s").str.split(by=" ")) shape: (3, 1) ┌───────────────────────┐ │ s │ │ --- │ │ list [str] │ ╞═══════════════════════╡ │ ["foo", "bar"] │ ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ │ ["foo-bar"] │ ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ │ ["foo", "bar", "baz"] │ └───────────────────────┘