Skip to content

Commit 4e76c25

Browse files
committed
added KProperties overloads for column, frameColumn, columnGroup.
added all overloads for col, colGroup, and frameCol in dsl with docs
1 parent c47f32c commit 4e76c25

File tree

10 files changed

+1198
-34
lines changed

10 files changed

+1198
-34
lines changed

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt

Lines changed: 800 additions & 14 deletions
Large diffs are not rendered by default.

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/constructors.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ import kotlin.reflect.typeOf
3737
public fun <T> column(): ColumnDelegate<T> = ColumnDelegate()
3838
public fun <T> column(name: String): ColumnAccessor<T> = ColumnAccessorImpl(name)
3939
public fun <T> column(path: ColumnPath): ColumnAccessor<T> = ColumnAccessorImpl(path)
40+
public fun <T> column(property: KProperty<T>): ColumnAccessor<T> = ColumnAccessorImpl(property.name)
4041
public fun <T> ColumnGroupReference.column(): ColumnDelegate<T> = ColumnDelegate(this)
4142
public fun <T> ColumnGroupReference.column(name: String): ColumnAccessor<T> = ColumnAccessorImpl(path() + name)
4243
public fun <T> ColumnGroupReference.column(path: ColumnPath): ColumnAccessor<T> = ColumnAccessorImpl(this.path() + path)
44+
public fun <T> ColumnGroupReference.column(property: KProperty<T>): ColumnAccessor<T> = ColumnAccessorImpl(this.path() + property.name)
4345

4446
public inline fun <reified T> column(
4547
name: String = "",
@@ -73,6 +75,11 @@ public fun columnGroup(path: ColumnPath): ColumnAccessor<AnyRow> = column(path)
7375
@JvmName("columnGroupTyped")
7476
public fun <T> columnGroup(path: ColumnPath): ColumnAccessor<DataRow<T>> = column(path)
7577

78+
@JvmName("columnGroupDataRowKProperty")
79+
public fun <T> columnGroup(property: KProperty<DataRow<T>>): ColumnAccessor<DataRow<T>> = column(property)
80+
81+
public fun <T> columnGroup(property: KProperty<T>): ColumnAccessor<DataRow<T>> = column(property.name)
82+
7683
public fun ColumnGroupReference.columnGroup(): ColumnDelegate<AnyRow> = ColumnDelegate(this)
7784

7885
@JvmName("columnGroupTyped")
@@ -91,6 +98,13 @@ public fun ColumnGroupReference.columnGroup(path: ColumnPath): ColumnAccessor<An
9198
public fun <T> ColumnGroupReference.columnGroup(path: ColumnPath): ColumnAccessor<DataRow<T>> =
9299
ColumnAccessorImpl(this.path() + path)
93100

101+
@JvmName("columnGroupDataRowKProperty")
102+
public fun <T> ColumnGroupReference.columnGroup(property: KProperty<DataRow<T>>): ColumnAccessor<DataRow<T>> =
103+
ColumnAccessorImpl(this.path() + property.name)
104+
105+
public fun <T> ColumnGroupReference.columnGroup(property: KProperty<T>): ColumnAccessor<DataRow<T>> =
106+
ColumnAccessorImpl(this.path() + property.name)
107+
94108
// endregion
95109

96110
// region frameColumn
@@ -110,6 +124,11 @@ public fun frameColumn(path: ColumnPath): ColumnAccessor<AnyFrame> = column(path
110124
@JvmName("frameColumnTyped")
111125
public fun <T> frameColumn(path: ColumnPath): ColumnAccessor<DataFrame<T>> = column(path)
112126

127+
@JvmName("frameColumnDataFrameKProperty")
128+
public fun <T> frameColumn(property: KProperty<DataFrame<T>>): ColumnAccessor<DataFrame<T>> = column(property)
129+
130+
public fun <T> frameColumn(property: KProperty<T>): ColumnAccessor<DataFrame<T>> = column(property.name)
131+
113132
public fun ColumnGroupReference.frameColumn(): ColumnDelegate<AnyFrame> = ColumnDelegate(this)
114133

115134
@JvmName("frameColumnTyped")
@@ -128,6 +147,13 @@ public fun ColumnGroupReference.frameColumn(path: ColumnPath): ColumnAccessor<An
128147
public fun <T> ColumnGroupReference.frameColumn(path: ColumnPath): ColumnAccessor<DataFrame<T>> =
129148
ColumnAccessorImpl(this.path() + path)
130149

150+
@JvmName("frameColumnDataFrameKProperty")
151+
public fun <T> ColumnGroupReference.frameColumn(property: KProperty<DataFrame<T>>): ColumnAccessor<DataFrame<T>> =
152+
ColumnAccessorImpl(this.path() + property.name)
153+
154+
public fun <T> ColumnGroupReference.frameColumn(property: KProperty<T>): ColumnAccessor<DataFrame<T>> =
155+
ColumnAccessorImpl(this.path() + property.name)
156+
131157
// endregion
132158

133159
public class ColumnDelegate<T>(private val parent: ColumnGroupReference? = null) {

core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Access.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ class Access : TestBase() {
817817

818818
// find the last column inside a column group satisfying the condition
819819
df.select {
820-
group("name").last { it.name().endsWith("Name") }
820+
colGroup("name").last { it.name().endsWith("Name") }
821821
}
822822

823823
// find the single column inside a column group satisfying the condition

core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Modify.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ class Modify : TestBase() {
527527
// SampleStart
528528
df.split { "name"["firstName"]<String>() }.by { it.chars().toList() }.intoRows()
529529

530-
df.split { group("name") }.by { it.values() }.intoRows()
530+
df.split { colGroup("name") }.by { it.values() }.intoRows()
531531
// SampleEnd
532532
}
533533

0 commit comments

Comments
 (0)