Column accessors API
For frequently accessed columns type casting can be reduced by Column Accessors:
val survived by column<Boolean>() // accessor for Boolean column with name 'survived'
val home by column<String>()
val age by column<Int?>()
val name by column<String>()
val lastName by column<String>()
Now columns can be accessed in a type-safe way using invoke
operator:
DataFrame.read("titanic.csv")
.add(lastName) { name().split(",").last() }
.dropNulls { age }
.filter { survived() && home().endsWith("NY") && age()!! in 10..20 }
The titanic.csv
file can be found here.
Last modified: 27 September 2024