@@ -4,6 +4,8 @@ import org.jetbrains.kotlinx.dataframe.ColumnsSelector
4
4
import org.jetbrains.kotlinx.dataframe.DataFrame
5
5
import org.jetbrains.kotlinx.dataframe.RowValueFilter
6
6
import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
7
+ import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
8
+ import org.jetbrains.kotlinx.dataframe.annotations.Refine
7
9
import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor
8
10
import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
9
11
import org.jetbrains.kotlinx.dataframe.columns.toColumnSet
@@ -15,6 +17,7 @@ import kotlin.reflect.typeOf
15
17
16
18
// region gather
17
19
20
+ @Interpretable(" Gather0" )
18
21
public fun <T , C > DataFrame<T>.gather (selector : ColumnsSelector <T , C >): Gather <T , C , String , C > =
19
22
Gather (
20
23
df = this ,
@@ -44,30 +47,76 @@ public fun <T, C> DataFrame<T>.gather(vararg columns: KProperty<C>): Gather<T, C
44
47
45
48
// endregion
46
49
50
+ @Interpretable(" GatherWhere" )
47
51
public 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
+ )
49
61
62
+ @Interpretable(" GatherChangeType" )
50
63
public 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 >
51
64
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
+ )
53
76
77
+ @Interpretable(" GatherMap" )
54
78
public inline fun <T , C , reified K , R > Gather <T , C , * , R >.mapKeys (
55
79
noinline transform : (String ) -> K ,
56
80
): 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
+ )
58
90
91
+ @Interpretable(" GatherMap" )
59
92
public 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
+ )
61
102
62
- public data class Gather <T , C , K , R >(
103
+ public class Gather <T , C , K , R >(
104
+ @PublishedApi
63
105
internal val df : DataFrame <T >,
106
+ @PublishedApi
64
107
internal val columns : ColumnsSelector <T , C >,
108
+ @PublishedApi
65
109
internal val filter : RowValueFilter <T , C >? = null ,
110
+ @PublishedApi
66
111
internal val keyType : KType ? = null ,
112
+ @PublishedApi
67
113
internal val keyTransform : ((String ) -> K ),
114
+ @PublishedApi
68
115
internal val valueTransform : ((C ) -> R )? = null ,
116
+ @PublishedApi
69
117
internal val explode : Boolean = false ,
70
118
) {
119
+ @Interpretable(" GatherChangeType" )
71
120
public fun <P > cast (): Gather <T , P , K , P > {
72
121
// TODO: introduce GatherWithTransform to avoid this error
73
122
require(valueTransform == null ) { " Cast is not allowed to be called after `mapValues`" }
@@ -77,6 +126,8 @@ public data class Gather<T, C, K, R>(
77
126
78
127
// region into
79
128
129
+ @Refine
130
+ @Interpretable(" GatherInto" )
80
131
public fun <T , C , K , R > Gather <T , C , K , R >.into (keyColumn : String , valueColumn : String ): DataFrame <T > =
81
132
gatherImpl(keyColumn, valueColumn)
82
133
@@ -100,6 +151,8 @@ public fun <T, C, K, R> Gather<T, C, K, R>.into(keyColumn: KProperty<K>, valueCo
100
151
101
152
// region keysInto
102
153
154
+ @Refine
155
+ @Interpretable(" GatherKeysInto" )
103
156
public fun <T , C , K , R > Gather <T , C , K , R >.keysInto (keyColumn : String ): DataFrame <T > = gatherImpl(keyColumn, null )
104
157
105
158
@Deprecated(
@@ -120,6 +173,8 @@ public fun <T, C, K, R> Gather<T, C, K, R>.keysInto(keyColumn: KProperty<K>): Da
120
173
121
174
// region valuesInto
122
175
176
+ @Refine
177
+ @Interpretable(" GatherValuesInto" )
123
178
public fun <T , C , K , R > Gather <T , C , K , R >.valuesInto (valueColumn : String ): DataFrame <T > = gatherImpl(null , valueColumn)
124
179
125
180
@Deprecated(
0 commit comments