datatable.FExpr.alias()

Assign new names to the columns from the current FExpr.

Parameters

names
str | List[str] | Tuple[str]

New names that should be assigned to the columns from the current FExpr.

return
FExpr

New FExpr which sets new names on the current one.

Examples

Create a frame:

from datatable import dt, f, by DT = dt.Frame([[1, 2, 3], ["one", "two", "three"]]) DT
C0C1
int32str32
01one
12two
23three

Assign new names when selecting data from the frame:

DT[:, f[:].alias("numbers", "strings")]
numbersstrings
int32str32
01one
12two
23three

Assign new name for the newly computed column only:

DT[:, [f[:], (f[0] * f[0]).alias("numbers_squared")]]
C0C1numbers_squared
int32str32int32
01one1
12two4
23three9

Assign new name for the group by column:

DT[:, f[1], by(f[0].alias("numbers"))]
numbersC1
int32str32
01one
12two
23three