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
C0 | C1 | ||
---|---|---|---|
int32 | str32 | ||
0 | 1 | one | |
1 | 2 | two | |
2 | 3 | three |
Assign new names when selecting data from the frame:
DT[:, f[:].alias("numbers", "strings")]
numbers | strings | ||
---|---|---|---|
int32 | str32 | ||
0 | 1 | one | |
1 | 2 | two | |
2 | 3 | three |
Assign new name for the newly computed column only:
DT[:, [f[:], (f[0] * f[0]).alias("numbers_squared")]]
C0 | C1 | numbers_squared | ||
---|---|---|---|---|
int32 | str32 | int32 | ||
0 | 1 | one | 1 | |
1 | 2 | two | 4 | |
2 | 3 | three | 9 |
Assign new name for the group by column:
DT[:, f[1], by(f[0].alias("numbers"))]
numbers | C1 | ||
---|---|---|---|
int32 | str32 | ||
0 | 1 | one | |
1 | 2 | two | |
2 | 3 | three |
The content on this page is licensed under the Creative Commons Attribution 4.0 License
(CC BY 4.0) ,
and code samples are licensed under the MIT License.