Files
2026-02-08 11:20:43 -10:00

1.9 KiB
Vendored

Creates List, DataFrame or DataColumn with values computed from rows of original DataFrame.

Related operations:

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 }
    expr { age > 18 } into "is adult"
    name.lastName.map { it.length } into "last name length"
    "full name" from { name.firstName + " " + name.lastName }
    +city
}
df.mapToFrame {
    "year of birth" from { 2021 - "age"<Int>() }
    expr { "age"<Int>() > 18 } into "is adult"
    "name"["lastName"]<String>().map { it.length } into "last name length"
    "full name" from { "name"["firstName"]<String>() + " " + "name"["lastName"]<String>() }
    +"city"
}