explode
Splits list-like values in given columns and spreads them vertically. Values in other columns are duplicated.
explode(dropEmpty = true) [ { columns } ]
Parameters:
dropEmpty
— iftrue
, removes rows with empty lists orDataFrame
objects. Otherwise, they will be exploded intonull
.
Available for:
DataColumn<Collection>
Reverse operation: implode
Exploded columns will change their types:
Exploded FrameColumn
will be converted into ColumnGroup
.
Explode DataFrame
:
val a by columnOf(1, 2)
val b by columnOf(listOf(1, 2), listOf(3, 4))
val df = dataFrameOf(a, b)
df.explode { b }
val df = dataFrameOf("a", "b")(
1, listOf(1, 2),
2, listOf(3, 4),
)
df.explode("b")
When several columns are exploded in one operation, lists in different columns will be aligned.
val a by columnOf(listOf(1, 2), listOf(3, 4, 5))
val b by columnOf(listOf(1, 2, 3), listOf(4, 5))
val df = dataFrameOf(a, b)
df.explode { a and b }
Explode DataColumn<Collection>
:
val col by columnOf(listOf(1, 2), listOf(3, 4))
col.explode()
Explode FrameColumn
:
val col by columnOf(
dataFrameOf("a", "b")(1, 2, 3, 4),
dataFrameOf("a", "b")(5, 6, 7, 8),
)
col.explode()
Last modified: 27 September 2024