mapToFrame
Returns a new DataFrame made of the columns described in body.
body describes the new columns with the AddDsl operations — from, into, expr, group, and the unary + that takes a column of this DataFrame as it is. The result holds only those columns, in the order in which they are described, and nothing else. This is what makes it different from add, where the columns of this DataFrame are also part of the result.
Every column computed from a row expression has one value per row of this DataFrame, in row order. An empty body describes no columns, so it gives a DataFrame with no columns and no rows.
See also:
The Map Operation— an overview of the wholemapfamily.add— the sameAddDsl, but the columns of thisDataFrameare kept as well.mapToColumn— a single new column instead of a wholeDataFrame.select— aDataFrameof chosen columns, when nothing has to be computed.
Example
// A frame of four new columns and a copy of "city";
// "name" and "age" of `df` are not in the result
df.mapToFrame {
"year of birth" from { 2021 - age }
expr { age > 18 } into "is adult"
name.lastName.map { it.length } into "last name length"
"full name" from { name.firstName + " " + name.lastName }
+city
}For more information: See mapToFrame on the documentation website.
Return
A new DataFrame with the described columns.