Similar to replace with operation, columns can be converted in a compiler plugin-friendly fashion whenever you need to perform an operation on the entire column without changing its name. For example, parallel reading.
df.convert { name }.asColumn { col ->
col.toList().parallelStream().map { it.toString() }.collect(Collectors.toList()).toColumn()
}
convert {}.to<>() supports automatic type conversions between the following types:
String, Char (uses parse to convert from String to other types)
Boolean
Byte
Short
Int (and Char)
Long
Float
Double (See parsing doubles for String to Double conversion)
BigDecimal
BigInteger
LocalDateTime (kotlinx.datetime and java.time)
LocalDate (kotlinx.datetime and java.time)
LocalTime (kotlinx.datetime and java.time)
Instant (kotlinx.datetime, kotlin.time, and java.time)
enum classes (by name)
If you want to convert Char'1' to the Int1, use parse() instead, or use String as intermediate type.
df.convert { age }.to<Double>()
df.convert { colsOf<Number>() }.to<String>()
df.convert { name.firstName and name.lastName }.asColumn { col -> col.map { it.length } }
df.convert { weight }.toFloat()
Automatic conversion from String to enum classes is also supported: