polars.Expr.name.suffix#

Expr.name.suffix(suffix: str) Expr[source]#

Add a suffix to the root column name of the expression.

Parameters:
suffix

Suffix to add to the root column name.

See also

prefix
map

Examples

>>> df = pl.DataFrame(
...     {
...         "a": [1, 2, 3],
...         "b": ["x", "y", "z"],
...     }
... )
>>> df.with_columns(pl.all().reverse().name.suffix("_reverse"))
shape: (3, 4)
┌─────┬─────┬───────────┬───────────┐
│ a   ┆ b   ┆ a_reverse ┆ b_reverse │
│ --- ┆ --- ┆ ---       ┆ ---       │
│ i64 ┆ str ┆ i64       ┆ str       │
╞═════╪═════╪═══════════╪═══════════╡
│ 1   ┆ x   ┆ 3         ┆ z         │
│ 2   ┆ y   ┆ 2         ┆ y         │
│ 3   ┆ z   ┆ 1         ┆ x         │
└─────┴─────┴───────────┴───────────┘