polars.Expr.alias#
- Expr.alias(name: str) Self [source]#
Rename the output of an expression.
- Parameters:
- name
New name.
Examples
>>> df = pl.DataFrame( ... { ... "a": [1, 2, 3], ... "b": ["a", "b", None], ... } ... ) >>> df shape: (3, 2) ┌─────┬──────┐ │ a ┆ b │ │ --- ┆ --- │ │ i64 ┆ str │ ╞═════╪══════╡ │ 1 ┆ a │ │ 2 ┆ b │ │ 3 ┆ null │ └─────┴──────┘ >>> df.select( ... pl.col("a").alias("bar"), ... pl.col("b").alias("foo"), ... ) shape: (3, 2) ┌─────┬──────┐ │ bar ┆ foo │ │ --- ┆ --- │ │ i64 ┆ str │ ╞═════╪══════╡ │ 1 ┆ a │ │ 2 ┆ b │ │ 3 ┆ null │ └─────┴──────┘