polars.Expr.str.concat#

Expr.str.concat(delimiter: str | None = None, *, ignore_nulls: bool = True) Expr[source]#

Vertically concatenate the string values in the column to a single string value.

Deprecated since version 1.0.0: Use join() instead. Note that the default delimiter for join() is an empty string instead of a hyphen.

Parameters:
delimiter

The delimiter to insert between consecutive string values.

ignore_nulls

Ignore null values (default). If set to False, null values will be propagated. This means that if the column contains any null values, the output is null.

Returns:
Expr

Expression of data type String.

Examples

>>> df = pl.DataFrame({"foo": [1, None, 2]})
>>> df.select(pl.col("foo").str.concat("-"))  
shape: (1, 1)
┌─────┐
│ foo │
│ --- │
│ str │
╞═════╡
│ 1-2 │
└─────┘
>>> df.select(
...     pl.col("foo").str.concat("-", ignore_nulls=False)
... )  
shape: (1, 1)
┌──────┐
│ foo  │
│ ---  │
│ str  │
╞══════╡
│ null │
└──────┘