From 3769ca2fe8024d2e4dd1670285d59483269cceb5 Mon Sep 17 00:00:00 2001 From: Nikita Klimenko Date: Thu, 23 Jan 2025 01:22:56 +0200 Subject: [PATCH] Add some AccessApiOverload annotations --- .../jetbrains/kotlinx/dataframe/DataRow.kt | 3 +++ .../kotlinx/dataframe/api/DataRowApi.kt | 2 ++ .../kotlinx/dataframe/api/countDistinct.kt | 3 +++ .../jetbrains/kotlinx/dataframe/api/cumSum.kt | 5 +++++ .../kotlinx/dataframe/api/describe.kt | 3 +++ .../jetbrains/kotlinx/dataframe/api/first.kt | 2 ++ .../kotlinx/dataframe/api/frameCols.kt | 2 ++ .../jetbrains/kotlinx/dataframe/api/insert.kt | 2 ++ .../jetbrains/kotlinx/dataframe/api/last.kt | 2 ++ .../jetbrains/kotlinx/dataframe/api/max.kt | 13 +++++++++++ .../jetbrains/kotlinx/dataframe/api/mean.kt | 7 ++++++ .../jetbrains/kotlinx/dataframe/api/median.kt | 9 ++++++++ .../jetbrains/kotlinx/dataframe/api/min.kt | 22 +++++++++++++++++++ .../jetbrains/kotlinx/dataframe/api/pivot.kt | 2 ++ .../jetbrains/kotlinx/dataframe/api/rename.kt | 14 ++++++++++++ .../kotlinx/dataframe/api/reorder.kt | 3 +++ .../jetbrains/kotlinx/dataframe/api/select.kt | 1 + .../jetbrains/kotlinx/dataframe/api/single.kt | 2 ++ .../jetbrains/kotlinx/dataframe/api/sort.kt | 2 ++ .../jetbrains/kotlinx/dataframe/api/take.kt | 5 +++++ .../kotlinx/dataframe/api/toDataFrame.kt | 3 +++ .../kotlinx/dataframe/api/valueCols.kt | 2 ++ .../kotlinx/dataframe/api/valueCounts.kt | 3 +++ .../jetbrains/kotlinx/dataframe/api/values.kt | 12 ++++++++++ .../kotlinx/dataframe/api/withoutNulls.kt | 2 ++ 25 files changed, 126 insertions(+) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataRow.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataRow.kt index 4eb543c244..8be75df4e3 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataRow.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataRow.kt @@ -28,13 +28,16 @@ public interface DataRow { public operator fun get(expression: RowExpression): R = expression(this, this) + @AccessApiOverload public operator fun get(column: ColumnReference): R + @AccessApiOverload public operator fun get(columns: List>): List = columns.map { get(it) } @AccessApiOverload public operator fun get(property: KProperty): R = get(property.columnName) as R + @AccessApiOverload public operator fun get(first: AnyColumnReference, vararg other: AnyColumnReference): DataRow = owner.get(first, *other)[index] diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataRowApi.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataRowApi.kt index 8a88448072..e669b38897 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataRowApi.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataRowApi.kt @@ -59,6 +59,7 @@ public fun AnyRow.namedValues(): List> = public fun AnyRow.getValue(columnName: String): T = get(columnName) as T +@AccessApiOverload public fun AnyRow.getValue(column: ColumnReference): T = get(column) @AccessApiOverload @@ -75,6 +76,7 @@ public fun AnyRow.getValueOrNull(column: KProperty): T? = getValueOrNull< public fun AnyRow.containsKey(columnName: String): Boolean = owner.containsColumn(columnName) +@AccessApiOverload public fun AnyRow.containsKey(column: AnyColumnReference): Boolean = owner.containsColumn(column) @AccessApiOverload diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/countDistinct.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/countDistinct.kt index 679d21dd11..edeebe6246 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/countDistinct.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/countDistinct.kt @@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.AnyFrame import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.toColumnSet import org.jetbrains.kotlinx.dataframe.indices import kotlin.reflect.KProperty @@ -19,9 +20,11 @@ public fun DataFrame.countDistinct(columns: ColumnsSelector): In public fun DataFrame.countDistinct(vararg columns: String): Int = countDistinct { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.countDistinct(vararg columns: KProperty): Int = countDistinct { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.countDistinct(vararg columns: AnyColumnReference): Int = countDistinct { columns.toColumnSet() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/cumSum.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/cumSum.kt index 4779d07437..679c5c2f98 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/cumSum.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/cumSum.kt @@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.toColumnSet import org.jetbrains.kotlinx.dataframe.impl.nothingType import org.jetbrains.kotlinx.dataframe.impl.nullableNothingType @@ -87,11 +88,13 @@ public fun DataFrame.cumSum( public fun DataFrame.cumSum(vararg columns: String, skipNA: Boolean = defaultCumSumSkipNA): DataFrame = cumSum(skipNA) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.cumSum( vararg columns: AnyColumnReference, skipNA: Boolean = defaultCumSumSkipNA, ): DataFrame = cumSum(skipNA) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.cumSum(vararg columns: KProperty<*>, skipNA: Boolean = defaultCumSumSkipNA): DataFrame = cumSum(skipNA) { columns.toColumnSet() } @@ -112,11 +115,13 @@ public fun GroupBy.cumSum( public fun GroupBy.cumSum(vararg columns: String, skipNA: Boolean = defaultCumSumSkipNA): GroupBy = cumSum(skipNA) { columns.toColumnSet() } +@AccessApiOverload public fun GroupBy.cumSum( vararg columns: AnyColumnReference, skipNA: Boolean = defaultCumSumSkipNA, ): GroupBy = cumSum(skipNA) { columns.toColumnSet() } +@AccessApiOverload public fun GroupBy.cumSum( vararg columns: KProperty<*>, skipNA: Boolean = defaultCumSumSkipNA, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/describe.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/describe.kt index 361b50f19f..319510c59d 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/describe.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/describe.kt @@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.DataSchema import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -49,9 +50,11 @@ public fun DataFrame.describe(columns: ColumnsSelector): DataFrame< public fun DataFrame.describe(vararg columns: String): DataFrame = describe { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.describe(vararg columns: ColumnReference): DataFrame = describe { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.describe(vararg columns: KProperty): DataFrame = describe { columns.toColumnSet() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/first.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/first.kt index 689fa34447..89880a0016 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/first.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/first.kt @@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowFilter +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -202,6 +203,7 @@ public interface FirstColumnsSelectionDsl { * * `df.`[select][DataFrame.select]` { DataSchemaType::myColumnGroup.`[firstCol][KProperty.firstCol]`() }` */ + @AccessApiOverload public fun KProperty<*>.firstCol(condition: ColumnFilter<*> = { true }): TransformableSingleColumn<*> = columnGroup(this).firstCol(condition) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frameCols.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frameCols.kt index c06626c55a..99acd05ee6 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frameCols.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frameCols.kt @@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.AnyFrame import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.Predicate +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -159,6 +160,7 @@ public interface FrameColsColumnsSelectionDsl { * * `df.`[select][DataFrame.select]` { DataSchemaType::myColGroup.`[frameCols][KProperty.frameCols]`() }` */ + @AccessApiOverload public fun KProperty<*>.frameCols( filter: Predicate> = { true }, ): TransformableColumnSet> = columnGroup(this).frameCols(filter) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/insert.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/insert.kt index fa67fd3b74..61f3b59e68 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/insert.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/insert.kt @@ -30,6 +30,7 @@ public inline fun DataFrame.insert( ): InsertClause = insert(mapToColumn(name, infer, expression)) @Interpretable("Insert2") +@AccessApiOverload public inline fun DataFrame.insert( column: ColumnAccessor, infer: Infer = Infer.Nulls, @@ -37,6 +38,7 @@ public inline fun DataFrame.insert( ): InsertClause = insert(column.name(), infer, expression) @Interpretable("Insert3") +@AccessApiOverload public inline fun DataFrame.insert( column: KProperty, infer: Infer = Infer.Nulls, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/last.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/last.kt index 6c7c217b87..622ceadd52 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/last.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/last.kt @@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowFilter +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -201,6 +202,7 @@ public interface LastColumnsSelectionDsl { * * `df.`[select][DataFrame.select]` { DataSchemaType::myColumnGroup.`[lastCol][KProperty.lastCol]`() }` */ + @AccessApiOverload public fun KProperty<*>.lastCol(condition: ColumnFilter<*> = { true }): TransformableSingleColumn<*> = columnGroup(this).lastCol(condition) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/max.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/max.kt index a3c6be2097..e64394fe23 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/max.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/max.kt @@ -153,6 +153,7 @@ public fun > Grouped.max(name: String? = null, columns: public fun Grouped.max(vararg columns: String, name: String? = null): DataFrame = max(name) { columns.toComparableColumns() } +@AccessApiOverload public fun > Grouped.max( vararg columns: ColumnReference, name: String? = null, @@ -195,11 +196,13 @@ public fun > Pivot.maxFor( public fun Pivot.maxFor(vararg columns: String, separate: Boolean = false): DataRow = maxFor(separate) { columns.toComparableColumns() } +@AccessApiOverload public fun > Pivot.maxFor( vararg columns: ColumnReference, separate: Boolean = false, ): DataRow = maxFor(separate) { columns.toColumnSet() } +@AccessApiOverload public fun > Pivot.maxFor( vararg columns: KProperty, separate: Boolean = false, @@ -209,9 +212,11 @@ public fun > Pivot.max(columns: ColumnsSelector): public fun Pivot.max(vararg columns: String): DataRow = max { columns.toComparableColumns() } +@AccessApiOverload public fun > Pivot.max(vararg columns: ColumnReference): DataRow = max { columns.toColumnSet() } +@AccessApiOverload public fun > Pivot.max(vararg columns: KProperty): DataRow = max { columns.toColumnSet() } @@ -221,12 +226,14 @@ public fun > Pivot.maxOf(rowExpression: RowExpression> Pivot.maxBy(rowExpression: RowExpression): ReducedPivot = reduce { maxByOrNull(rowExpression) } +@AccessApiOverload public fun > Pivot.maxBy(column: ColumnReference): ReducedPivot = reduce { maxByOrNull(column) } public fun Pivot.maxBy(column: String): ReducedPivot = maxBy(column.toColumnAccessor().cast>()) +@AccessApiOverload public fun > Pivot.maxBy(column: KProperty): ReducedPivot = maxBy(column.toColumnAccessor()) @@ -244,11 +251,13 @@ public fun > PivotGroupBy.maxFor( public fun PivotGroupBy.maxFor(vararg columns: String, separate: Boolean = false): DataFrame = maxFor(separate) { columns.toComparableColumns() } +@AccessApiOverload public fun > PivotGroupBy.maxFor( vararg columns: ColumnReference, separate: Boolean = false, ): DataFrame = maxFor(separate) { columns.toColumnSet() } +@AccessApiOverload public fun > PivotGroupBy.maxFor( vararg columns: KProperty, separate: Boolean = false, @@ -259,9 +268,11 @@ public fun > PivotGroupBy.max(columns: ColumnsSelector PivotGroupBy.max(vararg columns: String): DataFrame = max { columns.toComparableColumns() } +@AccessApiOverload public fun > PivotGroupBy.max(vararg columns: ColumnReference): DataFrame = max { columns.toColumnSet() } +@AccessApiOverload public fun > PivotGroupBy.max(vararg columns: KProperty): DataFrame = max { columns.toColumnSet() } @@ -271,12 +282,14 @@ public fun > PivotGroupBy.maxOf(rowExpression: RowExpres public fun > PivotGroupBy.maxBy(rowExpression: RowExpression): ReducedPivotGroupBy = reduce { maxByOrNull(rowExpression) } +@AccessApiOverload public fun > PivotGroupBy.maxBy(column: ColumnReference): ReducedPivotGroupBy = reduce { maxByOrNull(column) } public fun PivotGroupBy.maxBy(column: String): ReducedPivotGroupBy = maxBy(column.toColumnAccessor().cast>()) +@AccessApiOverload public fun > PivotGroupBy.maxBy(column: KProperty): ReducedPivotGroupBy = maxBy(column.toColumnAccessor()) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/mean.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/mean.kt index 0255e8fb93..994cbf27db 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/mean.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/mean.kt @@ -60,6 +60,7 @@ public fun DataFrame.meanFor( public fun DataFrame.meanFor(vararg columns: String, skipNA: Boolean = skipNA_default): DataRow = meanFor(skipNA) { columns.toNumberColumns() } +@AccessApiOverload public fun DataFrame.meanFor( vararg columns: ColumnReference, skipNA: Boolean = skipNA_default, @@ -79,6 +80,7 @@ public fun DataFrame.mean( public fun DataFrame.mean(vararg columns: String, skipNA: Boolean = skipNA_default): Double = mean(skipNA) { columns.toNumberColumns() } +@AccessApiOverload public fun DataFrame.mean( vararg columns: ColumnReference, skipNA: Boolean = skipNA_default, @@ -107,6 +109,7 @@ public fun Grouped.meanFor( public fun Grouped.meanFor(vararg columns: String, skipNA: Boolean = skipNA_default): DataFrame = meanFor(skipNA) { columns.toNumberColumns() } +@AccessApiOverload public fun Grouped.meanFor( vararg columns: ColumnReference, skipNA: Boolean = skipNA_default, @@ -130,6 +133,7 @@ public fun Grouped.mean( skipNA: Boolean = skipNA_default, ): DataFrame = mean(name, skipNA) { columns.toNumberColumns() } +@AccessApiOverload public fun Grouped.mean( vararg columns: ColumnReference, name: String? = null, @@ -168,6 +172,7 @@ public fun Pivot.meanFor( separate: Boolean = false, ): DataRow = meanFor(skipNA, separate) { columns.toNumberColumns() } +@AccessApiOverload public fun Pivot.meanFor( vararg columns: ColumnReference, skipNA: Boolean = skipNA_default, @@ -210,6 +215,7 @@ public fun PivotGroupBy.meanFor( skipNA: Boolean = skipNA_default, ): DataFrame = meanFor(skipNA, separate) { columns.toNumberColumns() } +@AccessApiOverload public fun PivotGroupBy.meanFor( vararg columns: ColumnReference, separate: Boolean = false, @@ -231,6 +237,7 @@ public fun PivotGroupBy.mean( public fun PivotGroupBy.mean(vararg columns: String, skipNA: Boolean = skipNA_default): DataFrame = mean(skipNA) { columns.toColumnsSetOf() } +@AccessApiOverload public fun PivotGroupBy.mean( vararg columns: ColumnReference, skipNA: Boolean = skipNA_default, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/median.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/median.kt index 0a353d7d4c..ccc8859fb5 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/median.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/median.kt @@ -61,6 +61,7 @@ public fun > DataFrame.medianFor(columns: ColumnsForAggr public fun DataFrame.medianFor(vararg columns: String): DataRow = medianFor { columns.toComparableColumns() } +@AccessApiOverload public fun > DataFrame.medianFor(vararg columns: ColumnReference): DataRow = medianFor { columns.toColumnSet() } @@ -73,6 +74,7 @@ public fun > DataFrame.median(columns: ColumnsSelector DataFrame.median(vararg columns: String): Any = median { columns.toComparableColumns() } +@AccessApiOverload public fun > DataFrame.median(vararg columns: ColumnReference): C = median { columns.toColumnSet() } @@ -85,6 +87,7 @@ public fun > DataFrame.medianOrNull(columns: ColumnsSele public fun DataFrame.medianOrNull(vararg columns: String): Any? = medianOrNull { columns.toComparableColumns() } +@AccessApiOverload public fun > DataFrame.medianOrNull(vararg columns: ColumnReference): C? = medianOrNull { columns.toColumnSet() } @@ -107,6 +110,7 @@ public fun > Grouped.medianFor(columns: ColumnsForAggreg public fun Grouped.medianFor(vararg columns: String): DataFrame = medianFor { columns.toComparableColumns() } +@AccessApiOverload public fun > Grouped.medianFor(vararg columns: ColumnReference): DataFrame = medianFor { columns.toColumnSet() } @@ -122,6 +126,7 @@ public fun > Grouped.median( public fun Grouped.median(vararg columns: String, name: String? = null): DataFrame = median(name) { columns.toComparableColumns() } +@AccessApiOverload public fun > Grouped.median( vararg columns: ColumnReference, name: String? = null, @@ -150,6 +155,7 @@ public fun > Pivot.medianFor( public fun Pivot.medianFor(vararg columns: String, separate: Boolean = false): DataRow = medianFor(separate) { columns.toComparableColumns() } +@AccessApiOverload public fun > Pivot.medianFor( vararg columns: ColumnReference, separate: Boolean = false, @@ -166,6 +172,7 @@ public fun > Pivot.median(columns: ColumnsSelector Pivot.median(vararg columns: String): DataRow = median { columns.toComparableColumns() } +@AccessApiOverload public fun > Pivot.median(vararg columns: ColumnReference): DataRow = median { columns.toColumnSet() } @@ -192,6 +199,7 @@ public fun > PivotGroupBy.medianFor( public fun PivotGroupBy.medianFor(vararg columns: String, separate: Boolean = false): DataFrame = medianFor(separate) { columns.toComparableColumns() } +@AccessApiOverload public fun > PivotGroupBy.medianFor( vararg columns: ColumnReference, separate: Boolean = false, @@ -208,6 +216,7 @@ public fun > PivotGroupBy.median(columns: ColumnsSelecto public fun PivotGroupBy.median(vararg columns: String): DataFrame = median { columns.toComparableColumns() } +@AccessApiOverload public fun > PivotGroupBy.median(vararg columns: ColumnReference): DataFrame = median { columns.toColumnSet() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/min.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/min.kt index ed6a59770d..8b421a305b 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/min.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/min.kt @@ -60,9 +60,11 @@ public fun > DataFrame.minFor(columns: ColumnsForAggrega public fun DataFrame.minFor(vararg columns: String): DataRow = minFor { columns.toComparableColumns() } +@AccessApiOverload public fun > DataFrame.minFor(vararg columns: ColumnReference): DataRow = minFor { columns.toColumnSet() } +@AccessApiOverload public fun > DataFrame.minFor(vararg columns: KProperty): DataRow = minFor { columns.toColumnSet() } @@ -71,9 +73,11 @@ public fun > DataFrame.min(columns: ColumnsSelector DataFrame.min(vararg columns: String): Comparable = minOrNull(*columns).suggestIfNull("min") +@AccessApiOverload public fun > DataFrame.min(vararg columns: ColumnReference): C = minOrNull(*columns).suggestIfNull("min") +@AccessApiOverload public fun > DataFrame.min(vararg columns: KProperty): C = minOrNull(*columns).suggestIfNull("min") @@ -83,9 +87,11 @@ public fun > DataFrame.minOrNull(columns: ColumnsSelecto public fun DataFrame.minOrNull(vararg columns: String): Comparable? = minOrNull { columns.toComparableColumns() } +@AccessApiOverload public fun > DataFrame.minOrNull(vararg columns: ColumnReference): C? = minOrNull { columns.toColumnSet() } +@AccessApiOverload public fun > DataFrame.minOrNull(vararg columns: KProperty): C? = minOrNull { columns.toColumnSet() } @@ -100,6 +106,7 @@ public fun > DataFrame.minBy(expression: RowExpression DataFrame.minBy(column: String): DataRow = minByOrNull(column).suggestIfNull("minBy") +@AccessApiOverload public fun > DataFrame.minBy(column: ColumnReference): DataRow = minByOrNull(column).suggestIfNull("minBy") @@ -113,6 +120,7 @@ public fun > DataFrame.minByOrNull(expression: RowExpres public fun DataFrame.minByOrNull(column: String): DataRow? = minByOrNull(column.toColumnOf?>()) +@AccessApiOverload public fun > DataFrame.minByOrNull(column: ColumnReference): DataRow? = getOrNull(get(column).asSequence().indexOfMin()) @@ -131,9 +139,11 @@ public fun > Grouped.minFor(columns: ColumnsForAggregate public fun Grouped.minFor(vararg columns: String): DataFrame = minFor { columns.toComparableColumns() } +@AccessApiOverload public fun > Grouped.minFor(vararg columns: ColumnReference): DataFrame = minFor { columns.toColumnSet() } +@AccessApiOverload public fun > Grouped.minFor(vararg columns: KProperty): DataFrame = minFor { columns.toColumnSet() } @@ -143,11 +153,13 @@ public fun > Grouped.min(name: String? = null, columns: public fun Grouped.min(vararg columns: String, name: String? = null): DataFrame = min(name) { columns.toComparableColumns() } +@AccessApiOverload public fun > Grouped.min( vararg columns: ColumnReference, name: String? = null, ): DataFrame = min(name) { columns.toColumnSet() } +@AccessApiOverload public fun > Grouped.min(vararg columns: KProperty, name: String? = null): DataFrame = min(name) { columns.toColumnSet() } @@ -159,6 +171,7 @@ public fun > Grouped.minOf( public fun > GroupBy.minBy(rowExpression: RowExpression): ReducedGroupBy = reduce { minByOrNull(rowExpression) } +@AccessApiOverload public fun > GroupBy.minBy(column: ColumnReference): ReducedGroupBy = reduce { minByOrNull(column) } @@ -183,11 +196,13 @@ public fun > Pivot.minFor( public fun Pivot.minFor(vararg columns: String, separate: Boolean = false): DataRow = minFor(separate) { columns.toComparableColumns() } +@AccessApiOverload public fun > Pivot.minFor( vararg columns: ColumnReference, separate: Boolean = false, ): DataRow = minFor(separate) { columns.toColumnSet() } +@AccessApiOverload public fun > Pivot.minFor( vararg columns: KProperty, separate: Boolean = false, @@ -198,9 +213,11 @@ public fun > Pivot.min(columns: ColumnsSelector): public fun > Pivot.min(vararg columns: String): DataRow = min { columns.toComparableColumns() } +@AccessApiOverload public fun > Pivot.min(vararg columns: ColumnReference): DataRow = min { columns.toColumnSet() } +@AccessApiOverload public fun > Pivot.min(vararg columns: KProperty): DataRow = min { columns.toColumnSet() } @@ -210,6 +227,7 @@ public fun > Pivot.minOf(rowExpression: RowExpression> Pivot.minBy(rowExpression: RowExpression): ReducedPivot = reduce { minByOrNull(rowExpression) } +@AccessApiOverload public fun > Pivot.minBy(column: ColumnReference): ReducedPivot = reduce { minByOrNull(column) } @@ -234,11 +252,13 @@ public fun > PivotGroupBy.minFor( public fun PivotGroupBy.minFor(vararg columns: String, separate: Boolean = false): DataFrame = minFor(separate) { columns.toComparableColumns() } +@AccessApiOverload public fun > PivotGroupBy.minFor( vararg columns: ColumnReference, separate: Boolean = false, ): DataFrame = minFor(separate) { columns.toColumnSet() } +@AccessApiOverload public fun > PivotGroupBy.minFor( vararg columns: KProperty, separate: Boolean = false, @@ -252,6 +272,7 @@ public fun PivotGroupBy.min(vararg columns: String): DataFrame = min { public fun > PivotGroupBy.min(vararg columns: ColumnReference): DataFrame = min { columns.toColumnSet() } +@AccessApiOverload public fun > PivotGroupBy.min(vararg columns: KProperty): DataFrame = min { columns.toColumnSet() } @@ -261,6 +282,7 @@ public fun > PivotGroupBy.minOf(rowExpression: RowExpres public fun > PivotGroupBy.minBy(rowExpression: RowExpression): ReducedPivotGroupBy = reduce { minByOrNull(rowExpression) } +@AccessApiOverload public fun > PivotGroupBy.minBy(column: ColumnReference): ReducedPivotGroupBy = reduce { minByOrNull(column) } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/pivot.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/pivot.kt index 9c7fcf9ac2..03dfaa0610 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/pivot.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/pivot.kt @@ -29,6 +29,7 @@ public interface PivotDsl : ColumnsSelectionDsl { public infix fun String.then(other: String): ColumnSet = toColumnAccessor() then other.toColumnAccessor() + @AccessApiOverload public infix fun KProperty.then(other: ColumnsResolver): ColumnSet = toColumnAccessor() then other @AccessApiOverload @@ -38,6 +39,7 @@ public interface PivotDsl : ColumnsSelectionDsl { public infix fun KProperty.then(other: KProperty): ColumnSet = toColumnAccessor() then other.toColumnAccessor() + @AccessApiOverload public infix fun KProperty.then(other: String): ColumnSet = toColumnAccessor() then other.toColumnOf() @AccessApiOverload diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt index 76744bbe43..a46dc9c438 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt @@ -260,6 +260,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.ColumnReferenceReceiver] * @include [CommonRenameDocs.ColumnReferenceParam] */ + @AccessApiOverload public infix fun ColumnReference.named(nameOf: ColumnReference<*>): ColumnReference = named(nameOf.name) /** @@ -268,6 +269,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.ColumnReferenceReceiver] * @include [CommonRenameDocs.KPropertyParam] */ + @AccessApiOverload public infix fun ColumnReference.named(nameOf: KProperty<*>): ColumnReference = named(nameOf.columnName) /** @@ -284,6 +286,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.StringReceiver] * @include [CommonRenameDocs.ColumnReferenceParam] */ + @AccessApiOverload public infix fun String.named(nameOf: ColumnReference<*>): ColumnReference<*> = toColumnAccessor().named(nameOf.name) @@ -293,6 +296,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.StringReceiver] * @include [CommonRenameDocs.KPropertyParam] */ + @AccessApiOverload public infix fun String.named(nameOf: KProperty<*>): ColumnReference<*> = toColumnAccessor().named(nameOf.columnName) @@ -302,6 +306,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.KPropertyReceiver] * @include [CommonRenameDocs.StringParam] */ + @AccessApiOverload public infix fun KProperty.named(newName: String): ColumnReference = toColumnAccessor().named(newName) /** @@ -310,6 +315,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.KPropertyReceiver] * @include [CommonRenameDocs.ColumnReferenceParam] */ + @AccessApiOverload public infix fun KProperty.named(nameOf: ColumnReference<*>): ColumnReference = toColumnAccessor().named(nameOf.name) @@ -319,6 +325,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.KPropertyReceiver] * @include [CommonRenameDocs.KPropertyParam] */ + @AccessApiOverload public infix fun KProperty.named(nameOf: KProperty<*>): ColumnReference = toColumnAccessor().named(nameOf.columnName) @@ -340,6 +347,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.ColumnReferenceReceiver] * @include [CommonRenameDocs.ColumnReferenceParam] */ + @AccessApiOverload public infix fun ColumnReference.into(nameOf: ColumnReference<*>): ColumnReference = named(nameOf) /** @@ -348,6 +356,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.ColumnReferenceReceiver] * @include [CommonRenameDocs.KPropertyParam] */ + @AccessApiOverload public infix fun ColumnReference.into(nameOf: KProperty<*>): ColumnReference = named(nameOf) /** @@ -364,6 +373,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.StringReceiver] * @include [CommonRenameDocs.ColumnReferenceParam] */ + @AccessApiOverload public infix fun String.into(nameOf: ColumnReference<*>): ColumnReference<*> = named(nameOf) /** @@ -372,6 +382,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.StringReceiver] * @include [CommonRenameDocs.KPropertyParam] */ + @AccessApiOverload public infix fun String.into(nameOf: KProperty<*>): ColumnReference<*> = named(nameOf) /** @@ -380,6 +391,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.KPropertyReceiver] * @include [CommonRenameDocs.StringParam] */ + @AccessApiOverload public infix fun KProperty.into(newName: String): ColumnReference = named(newName) /** @@ -388,6 +400,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.KPropertyReceiver] * @include [CommonRenameDocs.ColumnReferenceParam] */ + @AccessApiOverload public infix fun KProperty.into(nameOf: ColumnReference<*>): ColumnReference = named(nameOf) /** @@ -396,6 +409,7 @@ public interface RenameColumnsSelectionDsl { * @include [CommonRenameDocs.KPropertyReceiver] * @include [CommonRenameDocs.KPropertyParam] */ + @AccessApiOverload public infix fun KProperty.into(nameOf: KProperty<*>): ColumnReference = named(nameOf) // endregion diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/reorder.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/reorder.kt index 16ff44e000..c1b156466a 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/reorder.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/reorder.kt @@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.ColumnExpression import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.Selector +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.toColumnSet import org.jetbrains.kotlinx.dataframe.impl.api.reorderImpl @@ -22,9 +23,11 @@ public data class Reorder( public fun DataFrame.reorder(selector: ColumnsSelector): Reorder = Reorder(this, selector, false) +@AccessApiOverload public fun DataFrame.reorder(vararg columns: ColumnReference): Reorder = reorder { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.reorder(vararg columns: KProperty): Reorder = reorder { columns.toColumnSet() } public fun DataFrame.reorder(vararg columns: String): Reorder = reorder { columns.toColumnSet() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/select.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/select.kt index aa08ee5828..537841c193 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/select.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/select.kt @@ -187,6 +187,7 @@ public interface SelectColumnsSelectionDsl { * * `df.`[select][DataFrame.select]` { DataSchemaType::myColGroup `[`{`][KProperty.select]` colA `[and][ColumnsSelectionDsl.and]` colB `[`}`][KProperty.select]` }` */ + @AccessApiOverload public fun KProperty.select(selector: ColumnsSelector): ColumnSet = columnGroup(this).select(selector) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/single.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/single.kt index a02b290d00..c25a46bdd4 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/single.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/single.kt @@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowExpression +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.ColumnSet @@ -168,6 +169,7 @@ public interface SingleColumnsSelectionDsl { * * `df.`[select][DataFrame.select]` { DataSchemaType::myColumnGroup.`[singleCol][KProperty.singleCol]`() }` */ + @AccessApiOverload public fun KProperty<*>.singleCol(condition: ColumnFilter<*> = { true }): TransformableSingleColumn<*> = columnGroup(this).singleCol(condition) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/sort.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/sort.kt index ad3e4e60a0..c8b6579e70 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/sort.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/sort.kt @@ -34,6 +34,7 @@ public interface SortDsl : ColumnsSelectionDsl { public fun String.desc(): SingleColumn?> = invoke>().desc() + @AccessApiOverload public fun KProperty.desc(): SingleColumn = toColumnAccessor().desc() public fun ColumnSet.nullsLast(flag: Boolean = true): ColumnSet = @@ -45,6 +46,7 @@ public interface SortDsl : ColumnsSelectionDsl { public fun String.nullsLast(flag: Boolean = true): SingleColumn?> = invoke>().nullsLast(flag) + @AccessApiOverload public fun KProperty.nullsLast(flag: Boolean = true): SingleColumn = toColumnAccessor().nullsLast(flag) } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/take.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/take.kt index 0da37a1f06..4bb3001d0f 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/take.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/take.kt @@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowFilter +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnSet @@ -152,6 +153,7 @@ public interface TakeColumnsSelectionDsl { * * `df.`[select][DataFrame.select]` { DataSchemaType::myColumnGroup.`[takeCols][KProperty.takeCols]`(1) }` */ + @AccessApiOverload public fun KProperty<*>.takeCols(n: Int): ColumnSet<*> = columnGroup(this).takeCols(n) /** @@ -218,6 +220,7 @@ public interface TakeColumnsSelectionDsl { * * `df.`[select][DataFrame.select]` { DataSchemaType::myColumnGroup.`[takeLastCols][KProperty.takeLastCols]`(1) }` */ + @AccessApiOverload public fun KProperty<*>.takeLastCols(n: Int): ColumnSet<*> = columnGroup(this).takeLastCols(n) /** @@ -287,6 +290,7 @@ public interface TakeColumnsSelectionDsl { * * `df.`[select][DataFrame.select]` { DataSchemaType::myColumnGroup.`[takeColsWhile][KProperty.takeColsWhile]` { it.`[any][ColumnWithPath.any]` { it == "Alice" } } }` */ + @AccessApiOverload public fun KProperty<*>.takeColsWhile(predicate: ColumnFilter<*>): ColumnSet<*> = columnGroup(this).takeColsWhile(predicate) @@ -358,6 +362,7 @@ public interface TakeColumnsSelectionDsl { * * `df.`[select][DataFrame.select]` { DataSchemaType::myColumnGroup.`[takeLastColsWhile][KProperty.takeLastColsWhile]` { it.`[any][ColumnWithPath.any]` { it == "Alice" } } }` */ + @AccessApiOverload public fun KProperty<*>.takeLastColsWhile(predicate: ColumnFilter<*>): ColumnSet<*> = columnGroup(this).takeLastColsWhile(predicate) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt index 5809ae434f..b26eaf36a9 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt @@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.AnyFrame import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.DataSchema import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine @@ -186,12 +187,14 @@ public abstract class CreateDataFrameDsl : TraversePropertiesDsl { @Interpretable("ToDataFrameFrom0") public inline infix fun String.from(noinline expression: (T) -> R): Unit = add(this, expression) + @AccessApiOverload public inline infix fun KProperty.from(noinline expression: (T) -> R): Unit = add(columnName, expression) public inline infix fun String.from(inferType: InferType): Unit = add(DataColumn.createByInference(this, source.map { inferType.expression(it) })) + @AccessApiOverload public inline infix fun KProperty.from(inferType: InferType): Unit = add(DataColumn.createByInference(columnName, source.map { inferType.expression(it) })) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCols.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCols.kt index 47e617efb7..aafd23739a 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCols.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCols.kt @@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.Predicate +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.ColumnSet @@ -156,6 +157,7 @@ public interface ValueColsColumnsSelectionDsl { * * `df.`[select][DataFrame.select]` { DataSchemaType::myColumnGroup.`[valueCols][KProperty.valueCols]`() }` */ + @AccessApiOverload public fun KProperty<*>.valueCols(filter: Predicate> = { true }): TransformableColumnSet<*> = columnGroup(this).valueCols(filter) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCounts.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCounts.kt index 7cb52a9cc0..a0959c3990 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCounts.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCounts.kt @@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.DataSchema import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine @@ -82,6 +83,7 @@ public fun DataFrame.valueCounts( resultColumn: String = defaultCountColumnName, ): DataFrame = valueCounts(sort, ascending, dropNA, resultColumn) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.valueCounts( vararg columns: AnyColumnReference, sort: Boolean = true, @@ -90,6 +92,7 @@ public fun DataFrame.valueCounts( resultColumn: String = defaultCountColumnName, ): DataFrame = valueCounts(sort, ascending, dropNA, resultColumn) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.valueCounts( vararg columns: KProperty<*>, sort: Boolean = true, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/values.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/values.kt index e63509f618..c9f9db8e01 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/values.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/values.kt @@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.aggregation.ColumnsForAggregateSelector +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.toColumnSet import org.jetbrains.kotlinx.dataframe.impl.aggregation.columnValues import org.jetbrains.kotlinx.dataframe.impl.aggregation.internal @@ -28,6 +29,7 @@ public fun DataFrame.valuesNotNull(byRow: Boolean = false): Sequence // region GroupBy +@AccessApiOverload public fun Grouped.values( vararg columns: AnyColumnReference, dropNA: Boolean = false, @@ -55,11 +57,13 @@ public fun Grouped.values(dropNA: Boolean = false, distinct: Boolean = fa public fun ReducedGroupBy.values(): DataFrame = values(groupBy.remainingColumnsSelector()) +@AccessApiOverload public fun ReducedGroupBy.values(vararg columns: AnyColumnReference): DataFrame = values { columns.toColumnSet() } public fun ReducedGroupBy.values(vararg columns: String): DataFrame = values { columns.toColumnSet() } +@AccessApiOverload public fun ReducedGroupBy.values(vararg columns: KProperty<*>): DataFrame = values { columns.toColumnSet() } @@ -77,6 +81,7 @@ public fun Pivot.values( columns: ColumnsForAggregateSelector, ): DataRow = delegate { values(dropNA, distinct, separate, columns) } +@AccessApiOverload public fun Pivot.values( vararg columns: AnyColumnReference, dropNA: Boolean = false, @@ -91,6 +96,7 @@ public fun Pivot.values( separate: Boolean = false, ): DataRow = values(dropNA, distinct, separate) { columns.toColumnSet() } +@AccessApiOverload public fun Pivot.values( vararg columns: KProperty<*>, dropNA: Boolean = false, @@ -114,12 +120,14 @@ public fun Pivot.values( public fun ReducedPivot.values(separate: Boolean = false): DataRow = pivot.delegate { reduce(reducer).values(separate = separate) } +@AccessApiOverload public fun ReducedPivot.values(vararg columns: AnyColumnReference, separate: Boolean = false): DataRow = values(separate) { columns.toColumnSet() } public fun ReducedPivot.values(vararg columns: String, separate: Boolean = false): DataRow = values(separate) { columns.toColumnSet() } +@AccessApiOverload public fun ReducedPivot.values(vararg columns: KProperty<*>, separate: Boolean = false): DataRow = values(separate) { columns.toColumnSet() } @@ -138,6 +146,7 @@ public fun PivotGroupBy.values( separate: Boolean = false, ): DataFrame = values(dropNA, distinct, separate, remainingColumnsSelector()) +@AccessApiOverload public fun PivotGroupBy.values( vararg columns: AnyColumnReference, dropNA: Boolean = false, @@ -152,6 +161,7 @@ public fun PivotGroupBy.values( separate: Boolean = false, ): DataFrame = values(dropNA, distinct, separate) { columns.toColumnSet() } +@AccessApiOverload public fun PivotGroupBy.values( vararg columns: KProperty<*>, dropNA: Boolean = false, @@ -173,6 +183,7 @@ public fun PivotGroupBy.values( public fun ReducedPivotGroupBy.values(separate: Boolean = false): DataFrame = values(separate, pivot.remainingColumnsSelector()) +@AccessApiOverload public fun ReducedPivotGroupBy.values( vararg columns: AnyColumnReference, separate: Boolean = false, @@ -181,6 +192,7 @@ public fun ReducedPivotGroupBy.values( public fun ReducedPivotGroupBy.values(vararg columns: String, separate: Boolean = false): DataFrame = values(separate) { columns.toColumnSet() } +@AccessApiOverload public fun ReducedPivotGroupBy.values(vararg columns: KProperty<*>, separate: Boolean = false): DataFrame = values(separate) { columns.toColumnSet() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/withoutNulls.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/withoutNulls.kt index edec58b28b..f1a8e0a021 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/withoutNulls.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/withoutNulls.kt @@ -2,6 +2,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnSet @@ -125,6 +126,7 @@ public interface WithoutNullsColumnsSelectionDsl { * * `df.`[select][DataFrame.select]` { DataSchemaType::myColumnGroup.`[colsWithoutNulls][KProperty.colsWithoutNulls]`() }` */ + @AccessApiOverload public fun KProperty<*>.colsWithoutNulls(): ColumnSet = columnGroup(this).colsWithoutNulls() /**