map
Creates List
, DataFrame or DataColumn with values computed from rows of original DataFrame.
Map into List
:
map { rowExpression }: List<T>
rowExpression: DataRow.(DataRow) -> Value
df.map { 2021 - it.age }
Map into DataColumn
:
mapToColumn(columnName) { rowExpression }: DataColumn
rowExpression: DataRow.(DataRow) -> Value
df.mapToColumn("year of birth") { 2021 - age }
df.mapToColumn("year of birth") { 2021 - "age"<Int>() }
See row expressions
Map into DataFrame
:
mapToFrame {
columnMapping
columnMapping
...
} : DataFrame
columnMapping = column into columnName | columnName from column | columnName from { rowExpression } | +column
df.mapToFrame {
"year of birth" from 2021 - age
age gt 18 into "is adult"
name.lastName.length() into "last name length"
"full name" from { name.firstName + " " + name.lastName }
+city
}
df.mapToFrame {
"year of birth" from 2021 - "age"<Int>()
"age"<Int>() gt 18 into "is adult"
"name"["lastName"]<String>().length() into "last name length"
"full name" from { "name"["firstName"]<String>() + " " + "name"["lastName"]<String>() }
+"city"
}
20 May 2025