polars.Expr.map_alias#
- Expr.map_alias(function: Callable[[str], str]) Self [source]#
Rename the output of an expression by mapping a function over the root name.
- Parameters:
- function
Function that maps root name to new name.
Examples
>>> df = pl.DataFrame( ... { ... "A": [1, 2], ... "B": [3, 4], ... } ... ) >>> df.select( ... pl.all().reverse().map_alias(lambda colName: colName + "_reverse") ... ) shape: (2, 2) ┌───────────┬───────────┐ │ A_reverse ┆ B_reverse │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞═══════════╪═══════════╡ │ 2 ┆ 4 │ │ 1 ┆ 3 │ └───────────┴───────────┘