@@ -4,6 +4,8 @@ import org.jetbrains.kotlinx.dataframe.ColumnsSelector
44import org.jetbrains.kotlinx.dataframe.DataFrame
55import org.jetbrains.kotlinx.dataframe.RowValueFilter
66import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
7+ import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
8+ import org.jetbrains.kotlinx.dataframe.annotations.Refine
79import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor
810import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
911import org.jetbrains.kotlinx.dataframe.columns.toColumnSet
@@ -15,6 +17,7 @@ import kotlin.reflect.typeOf
1517
1618// region gather
1719
20+ @Interpretable(" Gather0" )
1821public fun <T , C > DataFrame<T>.gather (selector : ColumnsSelector <T , C >): Gather <T , C , String , C > =
1922 Gather (
2023 df = this ,
@@ -44,30 +47,76 @@ public fun <T, C> DataFrame<T>.gather(vararg columns: KProperty<C>): Gather<T, C
4447
4548// endregion
4649
50+ @Interpretable(" GatherWhere" )
4751public fun <T , C , K , R > Gather <T , C , K , R >.where (filter : RowValueFilter <T , C >): Gather <T , C , K , R > =
48- copy(filter = this .filter and filter)
52+ Gather (
53+ df = df,
54+ columns = columns,
55+ filter = this .filter and filter,
56+ keyType = keyType,
57+ keyTransform = keyTransform,
58+ valueTransform = valueTransform,
59+ explode = explode,
60+ )
4961
62+ @Interpretable(" GatherChangeType" )
5063public fun <T , C , K , R > Gather <T , C ?, K , R >.notNull (): Gather <T , C , K , R > = where { it != null } as Gather <T , C , K , R >
5164
52- public fun <T , C , K , R > Gather <T , C , K , R >.explodeLists (): Gather <T , C , K , R > = copy(explode = true )
65+ @Interpretable(" GatherExplodeLists" )
66+ public fun <T , C , K , R > Gather <T , C , K , R >.explodeLists (): Gather <T , C , K , R > =
67+ Gather (
68+ df = df,
69+ columns = columns,
70+ filter = filter,
71+ keyType = keyType,
72+ keyTransform = keyTransform,
73+ valueTransform = valueTransform,
74+ explode = true ,
75+ )
5376
77+ @Interpretable(" GatherMap" )
5478public inline fun <T , C , reified K , R > Gather <T , C , * , R >.mapKeys (
5579 noinline transform : (String ) -> K ,
5680): Gather <T , C , K , R > =
57- copy(keyTransform = transform as ((String ) -> Nothing ), keyType = typeOf<K >()) as Gather <T , C , K , R >
81+ Gather (
82+ df = df,
83+ columns = columns,
84+ filter = filter,
85+ keyType = typeOf<K >(),
86+ keyTransform = transform,
87+ valueTransform = valueTransform,
88+ explode = explode,
89+ )
5890
91+ @Interpretable(" GatherMap" )
5992public fun <T , C , K , R > Gather <T , C , K , * >.mapValues (transform : (C ) -> R ): Gather <T , C , K , R > =
60- copy(valueTransform = transform as ((C ) -> Nothing )) as Gather <T , C , K , R >
93+ Gather (
94+ df = df,
95+ columns = columns,
96+ filter = filter,
97+ keyType = keyType,
98+ keyTransform = keyTransform,
99+ valueTransform = transform,
100+ explode = explode,
101+ )
61102
62- public data class Gather <T , C , K , R >(
103+ public class Gather <T , C , K , R >(
104+ @PublishedApi
63105 internal val df : DataFrame <T >,
106+ @PublishedApi
64107 internal val columns : ColumnsSelector <T , C >,
108+ @PublishedApi
65109 internal val filter : RowValueFilter <T , C >? = null ,
110+ @PublishedApi
66111 internal val keyType : KType ? = null ,
112+ @PublishedApi
67113 internal val keyTransform : ((String ) -> K ),
114+ @PublishedApi
68115 internal val valueTransform : ((C ) -> R )? = null ,
116+ @PublishedApi
69117 internal val explode : Boolean = false ,
70118) {
119+ @Interpretable(" GatherChangeType" )
71120 public fun <P > cast (): Gather <T , P , K , P > {
72121 // TODO: introduce GatherWithTransform to avoid this error
73122 require(valueTransform == null ) { " Cast is not allowed to be called after `mapValues`" }
@@ -77,6 +126,8 @@ public data class Gather<T, C, K, R>(
77126
78127// region into
79128
129+ @Refine
130+ @Interpretable(" GatherInto" )
80131public fun <T , C , K , R > Gather <T , C , K , R >.into (keyColumn : String , valueColumn : String ): DataFrame <T > =
81132 gatherImpl(keyColumn, valueColumn)
82133
@@ -100,6 +151,8 @@ public fun <T, C, K, R> Gather<T, C, K, R>.into(keyColumn: KProperty<K>, valueCo
100151
101152// region keysInto
102153
154+ @Refine
155+ @Interpretable(" GatherKeysInto" )
103156public fun <T , C , K , R > Gather <T , C , K , R >.keysInto (keyColumn : String ): DataFrame <T > = gatherImpl(keyColumn, null )
104157
105158@Deprecated(
@@ -120,6 +173,8 @@ public fun <T, C, K, R> Gather<T, C, K, R>.keysInto(keyColumn: KProperty<K>): Da
120173
121174// region valuesInto
122175
176+ @Refine
177+ @Interpretable(" GatherValuesInto" )
123178public fun <T , C , K , R > Gather <T , C , K , R >.valuesInto (valueColumn : String ): DataFrame <T > = gatherImpl(null , valueColumn)
124179
125180@Deprecated(
0 commit comments