pyspark.sql.Column.alias

Column.alias(*alias: str, **kwargs: Any) → pyspark.sql.column.Column

Returns this column aliased with a new name or names (in the case of expressions that return more than one column, such as explode).

Parameters
aliasstr

desired column names (collects all positional arguments passed)

Other Parameters
metadata: dict

a dict of information to be stored in metadata attribute of the corresponding StructField (optional, keyword only argument)

Added optional metadata argument.

Examples

>>> df.select(df.age.alias("age2")).collect()
[Row(age2=2), Row(age2=5)]
>>> df.select(df.age.alias("age3", metadata={'max': 99})).schema['age3'].metadata['max']
99