I was working with a LocalDateTime which I wanted to split up into a LocalDate and a LocalTime column. I found the split operation, but it wasn't immediately obvious how to work with this. For splitting a column up based on String delimiters, something like
df.split { stringCol }.by { it.split(",") }.into("first", "second")
is clear and works well. However, when trying to split up a LocalDateTime:
df.split { localDateTimeCol }.by { listOf(it.date, it.time) }.into("date", "time")
does not seem obvious.
Something like
df.split { localDateTimeCol }.by { it.date and it.time }.into("date", "time")
would improve it a bit, and
df.split { localDateTimeCol }.by {
it.date into "date"
it.time into "time"
}
even more.
(Btw, since Split is a public data class, you're able to call df.split { myCol }.copy { } which looks like it should be prohibited)
I was working with a
LocalDateTimewhich I wanted to split up into aLocalDateand aLocalTimecolumn. I found thesplitoperation, but it wasn't immediately obvious how to work with this. For splitting a column up based on String delimiters, something likedf.split { stringCol }.by { it.split(",") }.into("first", "second")is clear and works well. However, when trying to split up a
LocalDateTime:df.split { localDateTimeCol }.by { listOf(it.date, it.time) }.into("date", "time")does not seem obvious.
Something like
df.split { localDateTimeCol }.by { it.date and it.time }.into("date", "time")would improve it a bit, and
df.split { localDateTimeCol }.by { it.date into "date" it.time into "time" }even more.
(Btw, since
Splitis apublic data class, you're able to calldf.split { myCol }.copy { }which looks like it should be prohibited)