explodeLists

fun <T, C, K, R> Gather<T, C, K, R>.explodeLists(): Gather<T, C, K, R>

Explodes List values — i.e., splits each list into individual elements, creating a separate row for each element, and duplicating all other columns — in the columns previously selected by gather.

If not all values are lists (for example, if one column contains Double values and another contains List<Double>), only the list values will be exploded — non-list values remain unchanged.

After explosion, operations like where, notNull, and mapValues are applied to individual list elements rather than to the lists themselves. To enable this, the resulting type should be explicitly specified using cast.

This is an intermediate step; returns a new Gather with exploded values.

For more information, see: See gather on the documentation website.

See also: Grammar.

Example

// Gather `resultA` and `resultB` columns into a single "value" column,
// with the "series" column containing a key.
// Assuming `resultA` contains `Double` values
// and `resultB` contains `List<Double>` values,
// `explodeLists` will apply only to values from `resultB`,
// resulting in all gathered values being of type `Double`.
df.gather { resultA and resultB }
.explodeLists()
.cast<Double>()
.mapValues { (it + 0.5).toFloat() }
.into("series", "value")

Return

A new Gather instance with exploded list values.

See also


@JvmName(name = "explodeListsTyped")
fun <T, C, K, R> Gather<T, List<C>, K, R>.explodeLists(): Gather<T, C, K, R>

Explodes List values in the columns previously selected by gather.

After explosion, operations like where, notNull, and mapValues are applied to individual list elements instead of the lists themselves.

This is an intermediate step; returns a new Gather with exploded values.

For more information, see: See gather on the documentation website.

See also: Grammar.

Example

// Gather `resultA` and `resultB` columns into a single "value" column,
// with the "series" column containing a key.
// Assuming `resultA` and `resultB` contain `List<Double>` values,
// `explodeLists` will produce individual `Double` elements.
df.gather { resultA and resultB }
.explodeLists()
.mapValues { (it + 0.5).toFloat() }
.into("series", "value")

Return

A new Gather instance with exploded list values.

See also