Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -2380,6 +2380,7 @@ public final class org/jetbrains/kotlinx/dataframe/api/Gather {

public final class org/jetbrains/kotlinx/dataframe/api/GatherKt {
public static final fun explodeLists (Lorg/jetbrains/kotlinx/dataframe/api/Gather;)Lorg/jetbrains/kotlinx/dataframe/api/Gather;
public static final fun explodeListsTyped (Lorg/jetbrains/kotlinx/dataframe/api/Gather;)Lorg/jetbrains/kotlinx/dataframe/api/Gather;
public static final fun gather (Lorg/jetbrains/kotlinx/dataframe/DataFrame;Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/kotlinx/dataframe/api/Gather;
public static final fun gather (Lorg/jetbrains/kotlinx/dataframe/DataFrame;[Ljava/lang/String;)Lorg/jetbrains/kotlinx/dataframe/api/Gather;
public static final fun gather (Lorg/jetbrains/kotlinx/dataframe/DataFrame;[Lkotlin/reflect/KProperty;)Lorg/jetbrains/kotlinx/dataframe/api/Gather;
Expand Down
13 changes: 13 additions & 0 deletions core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/gather.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ public fun <T, C, K, R> Gather<T, C, K, R>.explodeLists(): Gather<T, C, K, R> =
explode = true,
)

@JvmName("explodeListsTyped")
@Interpretable("GatherExplodeLists")
public fun <T, C, K, R> Gather<T, List<C>, K, R>.explodeLists(): Gather<T, C, K, R> =
Gather(
df = df,
columns = columns,
filter = filter,
keyType = keyType,
keyTransform = keyTransform,
valueTransform = valueTransform,
explode = true,
) as Gather<T, C, K, R>

@Interpretable("GatherMap")
public inline fun <T, C, reified K, R> Gather<T, C, *, R>.mapKeys(
noinline transform: (String) -> K,
Expand Down
15 changes: 15 additions & 0 deletions core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/gather.kt
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,19 @@ class GatherTests {
"b", 5,
)
}

@Test
fun `gather explode lists typed`() {
val df = dataFrameOf("list" to columnOf(listOf(1, 2, 3)))
.gather { "list"<List<Int>>() }
.explodeLists()
.mapValues { listOf(it) }
.into("key", "value")

df shouldBe dataFrameOf("key", "value")(
"list", listOf(1),
"list", listOf(2),
"list", listOf(3),
)
}
}