polars.Expr.list.concat#

Expr.list.concat(other: list[Expr | str] | Expr | str | Series | list[Any]) Expr[source]#

Concat the arrays in a Series dtype List in linear time.

Parameters:
other

Columns to concat into a List Series

Examples

>>> df = pl.DataFrame(
...     {
...         "a": [["a"], ["x"]],
...         "b": [["b", "c"], ["y", "z"]],
...     }
... )
>>> df.with_columns(concat=pl.col("a").list.concat("b"))
shape: (2, 3)
┌───────────┬────────────┬─────────────────┐
│ a         ┆ b          ┆ concat          │
│ ---       ┆ ---        ┆ ---             │
│ list[str] ┆ list[str]  ┆ list[str]       │
╞═══════════╪════════════╪═════════════════╡
│ ["a"]     ┆ ["b", "c"] ┆ ["a", "b", "c"] │
│ ["x"]     ┆ ["y", "z"] ┆ ["x", "y", "z"] │
└───────────┴────────────┴─────────────────┘