daft.Expression.alias

daft.Expression.alias#

Expression.alias(name: builtins.str) Expression[source]#

Gives the expression a new name, which is its column’s name in the DataFrame schema and the name by which subsequent expressions can refer to the results of this expression.

Example

>>> import daft
>>> df = daft.from_pydict({"x": [1, 2, 3]})
>>> df = df.select(col("x").alias("y"))
>>> df.show()
╭───────╮
│ y     │
│ ---   │
│ Int64 │
╞═══════╡
│ 1     │
├╌╌╌╌╌╌╌┤
│ 2     │
├╌╌╌╌╌╌╌┤
│ 3     │
╰───────╯

(Showing first 3 of 3 rows)
Parameters:

name – New name for expression

Returns:

Renamed expression

Return type:

Expression