assert_frame_equal.html)
    * [ polars.testing.assert_frame_not_equal ](../../api/polars.testing.assert_frame_not_equal.html)
    * [ polars.testing.assert_series_equal ](../../api/polars.testing.assert_series_equal.html)
    * [ polars.testing.assert_series_not_equal ](../../api/polars.testing.assert_series_not_equal.html)
    * [ polars.testing.parametric.dataframes ](../../api/polars.testing.parametric.dataframes.html)
    * [ polars.testing.parametric.series ](../../api/polars.testing.parametric.series.html)
    * [ polars.testing.parametric.column ](../../api/polars.testing.parametric.column.html)
    * [ polars.testing.parametric.columns ](../../api/polars.testing.parametric.columns.html)
    * [ polars.testing.parametric.create_list_strategy ](../../api/polars.testing.parametric.create_list_strategy.html)
    * [ polars.testing.parametric.load_profile ](../../api/polars.testing.parametric.load_profile.html)
    * [ polars.testing.parametric.set_profile ](../../api/polars.testing.parametric.set_profile.html)

  * [ Metadata ](../../metadata.html) __
    * [ polars.build_info ](../../api/polars.build_info.html)
    * [ polars.get_index_type ](../../api/polars.get_index_type.html)
    * [ polars.show_versions ](../../api/polars.show_versions.html)
    * [ polars.thread_pool_size ](../../api/polars.thread_pool_size.html)
    * [ polars.threadpool_size ](../../api/polars.threadpool_size.html)

  * [ __ ](../../../index.html)
  * [ Python API reference ](../../index.html)
  * __
  * [ Columns / names ](../columns.html)
  * polars.Expr.alias 

#  polars.Expr.alias  #

Expr.  alias  (  _ name  :  [ str
](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.12\)") _
)  →  Self  [ [source]  ](https://github.com/pola-rs/polars/blob/main/py-
polars/polars/expr/expr.py#L649-L707) #

    

Rename the expression.

Parameters  :

    

**name**

    

The new name.

See also

[ ` map  ` ](polars.map.html#polars.map "polars.map")

    
[ ` prefix  ` ](polars.Expr.prefix.html#polars.Expr.prefix
"polars.Expr.prefix")

    
[ ` suffix  ` ](polars.Expr.suffix.html#polars.Expr.suffix
"polars.Expr.suffix")

    

Examples

Rename an expression to avoid overwriting an existing column.

    
    
    >>> df = pl.DataFrame(
    ...     {
    ...         "a": [1, 2, 3],
    ...         "b": ["x", "y", "z"],
    ...     }
    ... )
    >>> df.with_columns(
    ...     pl.col("a") + 10,
    ...     pl.col("b").str.to_uppercase().alias("c"),
    ... )
    shape: (3, 3)
    ┌─────┬─────┬─────┐
    │ a   ┆ b   ┆ c   │
    │ --- ┆ --- ┆ --- │
    │ i64 ┆ str ┆ str │
    ╞═════╪═════╪═════╡
    │ 11  ┆ x   ┆ X   │
    │ 12  ┆ y   ┆ Y   │
    │ 13  ┆ z   ┆ Z   │
    └─────┴─────┴─────┘
    

Overwrite the default name of literal columns to prevent errors due to
duplicate column names.

    
    
    >>> df.with_columns(
    ...     pl.lit(True).alias("c"),
    ...     pl.lit(4.0).alias("d"),
    ... )
    shape: (3, 4)
    ┌─────┬─────┬──────┬─────┐
    │ a   ┆ b   ┆ c    ┆ d   │
    │ --- ┆ --- ┆ ---  ┆ --- │
    │ i64 ┆ str ┆ bool ┆ f64 │
    ╞═════╪═════╪══════╪═════╡
    │ 1   ┆ x   ┆ true ┆ 4.0 │
    │ 2   ┆ y   ┆ true ┆ 4.0 │
    │ 3   ┆ z   ┆ true ┆ 4.0 │
    └─────┴─────┴──────┴─────┘
    

[ __ previous  Columns / names  ](../columns.html "previous page") [ next
polars.Expr.exclude  __ ](polars.Expr.exclude.html "next page")

__ On this page

  * ` Expr.alias()  `

© Copyright 2020, Ritchie Vink.  

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.4.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.1.