From d162d43662640dcd40ed70425e5d73f9f05f7a69 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Wed, 22 Feb 2023 14:15:56 +0100 Subject: [PATCH] renamed Column typealias to AnyColumnReference --- .../jetbrains/kotlinx/dataframe/DataFrame.kt | 2 +- .../jetbrains/kotlinx/dataframe/DataRow.kt | 2 +- .../jetbrains/kotlinx/dataframe/aliases.kt | 2 +- .../dataframe/api/ColumnsSelectionDsl.kt | 19 +++++++++++------- .../kotlinx/dataframe/api/DataFrameGet.kt | 5 ++--- .../kotlinx/dataframe/api/DataRowApi.kt | 6 +++--- .../jetbrains/kotlinx/dataframe/api/Nulls.kt | 10 +++++----- .../jetbrains/kotlinx/dataframe/api/add.kt | 10 +++++----- .../kotlinx/dataframe/api/countDistinct.kt | 4 ++-- .../jetbrains/kotlinx/dataframe/api/cumSum.kt | 6 +++--- .../kotlinx/dataframe/api/distinct.kt | 10 +++++----- .../jetbrains/kotlinx/dataframe/api/group.kt | 6 +++--- .../kotlinx/dataframe/api/groupBy.kt | 8 ++++---- .../jetbrains/kotlinx/dataframe/api/move.kt | 16 +++++++-------- .../jetbrains/kotlinx/dataframe/api/pivot.kt | 20 +++++++++---------- .../jetbrains/kotlinx/dataframe/api/remove.kt | 10 +++++----- .../jetbrains/kotlinx/dataframe/api/select.kt | 6 +++--- .../kotlinx/dataframe/api/toDataFrame.kt | 4 ++-- .../jetbrains/kotlinx/dataframe/api/unfold.kt | 4 ++-- .../kotlinx/dataframe/api/ungroup.kt | 4 ++-- .../kotlinx/dataframe/api/valueCounts.kt | 4 ++-- .../jetbrains/kotlinx/dataframe/api/values.kt | 14 ++++++------- .../jetbrains/kotlinx/dataframe/api/with.kt | 4 ++-- .../impl/aggregation/aggregations.kt | 4 ++-- .../kotlinx/dataframe/impl/api/move.kt | 4 ++-- 25 files changed, 94 insertions(+), 90 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataFrame.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataFrame.kt index dd1c55636..9698f9630 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataFrame.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataFrame.kt @@ -57,7 +57,7 @@ public interface DataFrame : Aggregatable, ColumnsContainer { override operator fun get(columns: ColumnsSelector): List> = getColumnsImpl(UnresolvedColumnsPolicy.Fail, columns) - public operator fun get(first: Column, vararg other: Column): DataFrame = select(listOf(first) + other) + public operator fun get(first: AnyColumnReference, vararg other: AnyColumnReference): DataFrame = select(listOf(first) + other) public operator fun get(first: String, vararg other: String): DataFrame = select(listOf(first) + other) public operator fun get(columnRange: ClosedRange): DataFrame = select { columnRange.start..columnRange.endInclusive } 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 989fb3df2..5a1375436 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataRow.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataRow.kt @@ -28,7 +28,7 @@ public interface DataRow { public operator fun get(column: ColumnReference): R public operator fun get(columns: List>): List = columns.map { get(it) } public operator fun get(property: KProperty): R = get(property.columnName) as R - public operator fun get(first: Column, vararg other: Column): DataRow = owner.get(first, *other)[index] + public operator fun get(first: AnyColumnReference, vararg other: AnyColumnReference): DataRow = owner.get(first, *other)[index] public operator fun get(first: String, vararg other: String): DataRow = owner.get(first, *other)[index] public operator fun get(path: ColumnPath): Any? = owner.get(path)[index] public operator fun get(name: String): Any? diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aliases.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aliases.kt index c7d63224e..74552bae8 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aliases.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aliases.kt @@ -138,7 +138,7 @@ public typealias RowValueFilter = RowValueExpression // region columns -public typealias Column = ColumnReference<*> +public typealias AnyColumnReference = ColumnReference<*> public typealias ColumnGroupReference = ColumnReference public typealias ColumnGroupAccessor = ColumnAccessor> diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt index 66b47de17..60ca70a44 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt @@ -1,10 +1,15 @@ package org.jetbrains.kotlinx.dataframe.api -import org.jetbrains.kotlinx.dataframe.* +import org.jetbrains.kotlinx.dataframe.AnyCol +import org.jetbrains.kotlinx.dataframe.AnyColumnReference +import org.jetbrains.kotlinx.dataframe.AnyRow import org.jetbrains.kotlinx.dataframe.ColumnFilter +import org.jetbrains.kotlinx.dataframe.ColumnGroupReference import org.jetbrains.kotlinx.dataframe.ColumnsContainer import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataColumn +import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.Predicate import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup @@ -16,6 +21,7 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath import org.jetbrains.kotlinx.dataframe.columns.FrameColumn import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.renamedReference +import org.jetbrains.kotlinx.dataframe.hasNulls import org.jetbrains.kotlinx.dataframe.impl.columnName import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnsList import org.jetbrains.kotlinx.dataframe.impl.columns.DistinctColumnSet @@ -31,7 +37,6 @@ import org.jetbrains.kotlinx.dataframe.impl.columns.top import org.jetbrains.kotlinx.dataframe.impl.columns.transform import org.jetbrains.kotlinx.dataframe.impl.columns.transformSingle import org.jetbrains.kotlinx.dataframe.impl.columns.tree.dfs -import org.jetbrains.kotlinx.dataframe.impl.getColumnsWithPaths import kotlin.reflect.KProperty import kotlin.reflect.KType import kotlin.reflect.typeOf @@ -67,7 +72,7 @@ public interface ColumnsSelectionDsl : ColumnSelectionDsl, SingleColum public operator fun String.rangeTo(endInclusive: String): ColumnSet<*> = toColumnAccessor().rangeTo(endInclusive.toColumnAccessor()) - public operator fun Column.rangeTo(endInclusive: Column): ColumnSet<*> = object : ColumnSet { + public operator fun AnyColumnReference.rangeTo(endInclusive: AnyColumnReference): ColumnSet<*> = object : ColumnSet { override fun resolve(context: ColumnResolutionContext): List> { val startPath = this@rangeTo.resolveSingle(context)!!.path val endPath = endInclusive.resolveSingle(context)!!.path @@ -161,7 +166,7 @@ public interface ColumnsSelectionDsl : ColumnSelectionDsl, SingleColum } public fun SingleColumn<*>.allAfter(colName: String): ColumnSet = allAfter(pathOf(colName)) - public fun SingleColumn<*>.allAfter(column: Column): ColumnSet = allAfter(column.path()) + public fun SingleColumn<*>.allAfter(column: AnyColumnReference): ColumnSet = allAfter(column.path()) // endregion @@ -180,7 +185,7 @@ public interface ColumnsSelectionDsl : ColumnSelectionDsl, SingleColum } public fun SingleColumn<*>.allSince(colName: String): ColumnSet = allSince(pathOf(colName)) - public fun SingleColumn<*>.allSince(column: Column): ColumnSet = allSince(column.path()) + public fun SingleColumn<*>.allSince(column: AnyColumnReference): ColumnSet = allSince(column.path()) // endregion @@ -199,7 +204,7 @@ public interface ColumnsSelectionDsl : ColumnSelectionDsl, SingleColum } public fun SingleColumn<*>.allBefore(colName: String): ColumnSet = allBefore(pathOf(colName)) - public fun SingleColumn<*>.allBefore(column: Column): ColumnSet = allBefore(column.path()) + public fun SingleColumn<*>.allBefore(column: AnyColumnReference): ColumnSet = allBefore(column.path()) // endregion @@ -218,7 +223,7 @@ public interface ColumnsSelectionDsl : ColumnSelectionDsl, SingleColum } public fun SingleColumn<*>.allUntil(colName: String): ColumnSet = allUntil(pathOf(colName)) - public fun SingleColumn<*>.allUntil(column: Column): ColumnSet = allUntil(column.path()) + public fun SingleColumn<*>.allUntil(column: AnyColumnReference): ColumnSet = allUntil(column.path()) // endregion diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataFrameGet.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataFrameGet.kt index 8a49a3aa4..354d5990d 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataFrameGet.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataFrameGet.kt @@ -1,7 +1,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.AnyCol -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnSelector import org.jetbrains.kotlinx.dataframe.ColumnsContainer import org.jetbrains.kotlinx.dataframe.ColumnsSelector @@ -19,7 +19,6 @@ import org.jetbrains.kotlinx.dataframe.impl.columns.asAnyFrameColumn import org.jetbrains.kotlinx.dataframe.impl.columns.toColumns import org.jetbrains.kotlinx.dataframe.impl.getColumnPaths import org.jetbrains.kotlinx.dataframe.impl.getColumnsWithPaths -import org.jetbrains.kotlinx.dataframe.indices import org.jetbrains.kotlinx.dataframe.ncol import org.jetbrains.kotlinx.dataframe.nrow import kotlin.reflect.KProperty @@ -89,7 +88,7 @@ public fun ColumnsContainer.getColumnGroupOrNull(column: KProperty<*>): C public fun ColumnsContainer<*>.containsColumn(column: ColumnReference): Boolean = getColumnOrNull(column) != null public fun ColumnsContainer<*>.containsColumn(column: KProperty<*>): Boolean = containsColumn(column.columnName) -public operator fun ColumnsContainer<*>.contains(column: Column): Boolean = containsColumn(column) +public operator fun ColumnsContainer<*>.contains(column: AnyColumnReference): Boolean = containsColumn(column) public operator fun ColumnsContainer<*>.contains(column: KProperty<*>): Boolean = containsColumn(column) // region rows 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 9cdc67e72..d7987f5c4 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 @@ -1,7 +1,7 @@ package org.jetbrains.kotlinx.dataframe.api +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.AnyRow -import org.jetbrains.kotlinx.dataframe.Column import org.jetbrains.kotlinx.dataframe.ColumnsContainer import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame @@ -57,10 +57,10 @@ public fun AnyRow.getValueOrNull(column: KProperty): T? = getValueOrNull< // region contains public fun AnyRow.containsKey(columnName: String): Boolean = owner.containsColumn(columnName) -public fun AnyRow.containsKey(column: Column): Boolean = owner.containsColumn(column) +public fun AnyRow.containsKey(column: AnyColumnReference): Boolean = owner.containsColumn(column) public fun AnyRow.containsKey(column: KProperty<*>): Boolean = owner.containsColumn(column) -public operator fun AnyRow.contains(column: Column): Boolean = containsKey(column) +public operator fun AnyRow.contains(column: AnyColumnReference): Boolean = containsKey(column) public operator fun AnyRow.contains(column: KProperty<*>): Boolean = containsKey(column) // endregion diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/Nulls.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/Nulls.kt index 14daf12e8..0da816c0f 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/Nulls.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/Nulls.kt @@ -1,9 +1,9 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.AnyCol +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.AnyFrame import org.jetbrains.kotlinx.dataframe.AnyRow -import org.jetbrains.kotlinx.dataframe.Column import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame @@ -109,10 +109,10 @@ public fun DataFrame.dropNulls(vararg cols: KProperty<*>, whereAllNull: B public fun DataFrame.dropNulls(vararg cols: String, whereAllNull: Boolean = false): DataFrame = dropNulls(whereAllNull) { cols.toColumns() } -public fun DataFrame.dropNulls(vararg cols: Column, whereAllNull: Boolean = false): DataFrame = +public fun DataFrame.dropNulls(vararg cols: AnyColumnReference, whereAllNull: Boolean = false): DataFrame = dropNulls(whereAllNull) { cols.toColumns() } -public fun DataFrame.dropNulls(cols: Iterable, whereAllNull: Boolean = false): DataFrame = +public fun DataFrame.dropNulls(cols: Iterable, whereAllNull: Boolean = false): DataFrame = dropNulls(whereAllNull) { cols.toColumnSet() } public fun DataColumn.dropNulls(): DataColumn = @@ -135,10 +135,10 @@ public fun DataFrame.dropNA(vararg cols: KProperty<*>, whereAllNA: Boolea public fun DataFrame.dropNA(vararg cols: String, whereAllNA: Boolean = false): DataFrame = dropNA(whereAllNA) { cols.toColumns() } -public fun DataFrame.dropNA(vararg cols: Column, whereAllNA: Boolean = false): DataFrame = +public fun DataFrame.dropNA(vararg cols: AnyColumnReference, whereAllNA: Boolean = false): DataFrame = dropNA(whereAllNA) { cols.toColumns() } -public fun DataFrame.dropNA(cols: Iterable, whereAllNA: Boolean = false): DataFrame = +public fun DataFrame.dropNA(cols: Iterable, whereAllNA: Boolean = false): DataFrame = dropNA(whereAllNA) { cols.toColumnSet() } public fun DataFrame.dropNA(whereAllNA: Boolean = false): DataFrame = diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/add.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/add.kt index 513840c08..58c3c4804 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/add.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/add.kt @@ -3,9 +3,9 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.AnyBaseCol import org.jetbrains.kotlinx.dataframe.AnyCol import org.jetbrains.kotlinx.dataframe.AnyColumnGroupAccessor +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.AnyFrame import org.jetbrains.kotlinx.dataframe.AnyRow -import org.jetbrains.kotlinx.dataframe.Column import org.jetbrains.kotlinx.dataframe.ColumnsContainer import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame @@ -149,9 +149,9 @@ public class AddDsl(@PublishedApi internal val df: DataFrame) : ColumnsCon // TODO: support adding column into path internal val columns = mutableListOf() - public fun add(column: Column): Boolean = columns.add(column.resolveSingle(df)!!.data) + public fun add(column: AnyColumnReference): Boolean = columns.add(column.resolveSingle(df)!!.data) - public operator fun Column.unaryPlus(): Boolean = add(this) + public operator fun AnyColumnReference.unaryPlus(): Boolean = add(this) public operator fun String.unaryPlus(): Boolean = add(df[this]) @@ -172,11 +172,11 @@ public class AddDsl(@PublishedApi internal val df: DataFrame) : ColumnsCon public inline infix fun ColumnAccessor.from(noinline expression: RowExpression): Boolean = name().from(expression) public inline infix fun KProperty.from(noinline expression: RowExpression): Boolean = add(name, Infer.Nulls, expression) - public infix fun String.from(column: Column): Boolean = add(column.rename(this)) + public infix fun String.from(column: AnyColumnReference): Boolean = add(column.rename(this)) public inline infix fun ColumnAccessor.from(column: ColumnReference): Boolean = name() from column public inline infix fun KProperty.from(column: ColumnReference): Boolean = name from column - public infix fun Column.into(name: String): Boolean = add(rename(name)) + public infix fun AnyColumnReference.into(name: String): Boolean = add(rename(name)) public infix fun ColumnReference.into(column: ColumnAccessor): Boolean = into(column.name()) public infix fun ColumnReference.into(column: KProperty): Boolean = into(column.name) 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 37cfdb6c9..e93f7c04d 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 @@ -1,7 +1,7 @@ package org.jetbrains.kotlinx.dataframe.api +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.AnyFrame -import org.jetbrains.kotlinx.dataframe.Column import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.impl.columns.toColumns @@ -19,6 +19,6 @@ public fun DataFrame.countDistinct(columns: ColumnsSelector): In public fun DataFrame.countDistinct(vararg columns: String): Int = countDistinct { columns.toColumns() } public fun DataFrame.countDistinct(vararg columns: KProperty): Int = countDistinct { columns.toColumns() } -public fun DataFrame.countDistinct(vararg columns: Column): Int = countDistinct { columns.toColumns() } +public fun DataFrame.countDistinct(vararg columns: AnyColumnReference): Int = countDistinct { columns.toColumns() } // endregion 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 be60508cd..f67760cf3 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 @@ -1,6 +1,6 @@ package org.jetbrains.kotlinx.dataframe.api -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame @@ -38,7 +38,7 @@ private val supportedClasses = setOf(Double::class, Float::class, Int::class, Lo public fun DataFrame.cumSum(skipNA: Boolean = defaultCumSumSkipNA, columns: ColumnsSelector): DataFrame = convert(columns).to { if (it.typeClass in supportedClasses) it.cast().cumSum(skipNA) else it } public fun DataFrame.cumSum(vararg columns: String, skipNA: Boolean = defaultCumSumSkipNA): DataFrame = cumSum(skipNA) { columns.toColumns() } -public fun DataFrame.cumSum(vararg columns: Column, skipNA: Boolean = defaultCumSumSkipNA): DataFrame = cumSum(skipNA) { columns.toColumns() } +public fun DataFrame.cumSum(vararg columns: AnyColumnReference, skipNA: Boolean = defaultCumSumSkipNA): DataFrame = cumSum(skipNA) { columns.toColumns() } public fun DataFrame.cumSum(vararg columns: KProperty<*>, skipNA: Boolean = defaultCumSumSkipNA): DataFrame = cumSum(skipNA) { columns.toColumns() } public fun DataFrame.cumSum(skipNA: Boolean = defaultCumSumSkipNA): DataFrame = cumSum(skipNA) { allDfs() } @@ -50,7 +50,7 @@ public fun DataFrame.cumSum(skipNA: Boolean = defaultCumSumSkipNA): DataF public fun GroupBy.cumSum(skipNA: Boolean = defaultCumSumSkipNA, columns: ColumnsSelector): GroupBy = updateGroups { cumSum(skipNA, columns) } public fun GroupBy.cumSum(vararg columns: String, skipNA: Boolean = defaultCumSumSkipNA): GroupBy = cumSum(skipNA) { columns.toColumns() } -public fun GroupBy.cumSum(vararg columns: Column, skipNA: Boolean = defaultCumSumSkipNA): GroupBy = cumSum(skipNA) { columns.toColumns() } +public fun GroupBy.cumSum(vararg columns: AnyColumnReference, skipNA: Boolean = defaultCumSumSkipNA): GroupBy = cumSum(skipNA) { columns.toColumns() } public fun GroupBy.cumSum(vararg columns: KProperty<*>, skipNA: Boolean = defaultCumSumSkipNA): GroupBy = cumSum(skipNA) { columns.toColumns() } public fun GroupBy.cumSum(skipNA: Boolean = defaultCumSumSkipNA): GroupBy = cumSum(skipNA) { allDfs() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/distinct.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/distinct.kt index c0c072c33..7c72af4e6 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/distinct.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/distinct.kt @@ -1,6 +1,6 @@ package org.jetbrains.kotlinx.dataframe.api -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.impl.columns.toColumnSet @@ -18,19 +18,19 @@ public fun DataFrame.distinct(vararg columns: KProperty<*>): DataFrame set } public fun DataFrame.distinct(vararg columns: String): DataFrame = distinct { columns.toColumns() } -public fun DataFrame.distinct(vararg columns: Column): DataFrame = distinct { columns.toColumns() } +public fun DataFrame.distinct(vararg columns: AnyColumnReference): DataFrame = distinct { columns.toColumns() } @JvmName("distinctT") public fun DataFrame.distinct(columns: Iterable): DataFrame = distinct { columns.toColumns() } -public fun DataFrame.distinct(columns: Iterable): DataFrame = distinct { columns.toColumnSet() } +public fun DataFrame.distinct(columns: Iterable): DataFrame = distinct { columns.toColumnSet() } public fun DataFrame.distinctBy(vararg columns: KProperty<*>): DataFrame = distinctBy { columns.toColumns() } public fun DataFrame.distinctBy(vararg columns: String): DataFrame = distinctBy { columns.toColumns() } -public fun DataFrame.distinctBy(vararg columns: Column): DataFrame = distinctBy { columns.toColumns() } +public fun DataFrame.distinctBy(vararg columns: AnyColumnReference): DataFrame = distinctBy { columns.toColumns() } @JvmName("distinctByT") public fun DataFrame.distinctBy(columns: Iterable): DataFrame = distinctBy { columns.toColumns() } -public fun DataFrame.distinctBy(columns: Iterable): DataFrame = distinctBy { columns.toColumnSet() } +public fun DataFrame.distinctBy(columns: Iterable): DataFrame = distinctBy { columns.toColumnSet() } public fun DataFrame.distinctBy(columns: ColumnsSelector): DataFrame { val cols = get(columns) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/group.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/group.kt index 2c75681d3..c83f2db3f 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/group.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/group.kt @@ -1,7 +1,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.AnyColumnGroupAccessor -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath @@ -16,7 +16,7 @@ public data class GroupClause(val df: DataFrame, val columns: ColumnsSe public fun DataFrame.group(columns: ColumnsSelector): GroupClause = GroupClause(this, columns) public fun DataFrame.group(vararg columns: String): GroupClause = group { columns.toColumns() } -public fun DataFrame.group(vararg columns: Column): GroupClause = group { columns.toColumns() } +public fun DataFrame.group(vararg columns: AnyColumnReference): GroupClause = group { columns.toColumns() } public fun DataFrame.group(vararg columns: KProperty<*>): GroupClause = group { columns.toColumns() } @JvmName("intoString") @@ -25,7 +25,7 @@ public fun DataFrame.group(vararg columns: KProperty<*>): GroupClause GroupClause.into(column: ColumnsSelectionDsl.(ColumnWithPath) -> String): DataFrame = df.move(columns).under { column(it).toColumnAccessor() } @JvmName("intoColumn") -public infix fun GroupClause.into(column: ColumnsSelectionDsl.(ColumnWithPath) -> Column): DataFrame = df.move(columns).under(column) +public infix fun GroupClause.into(column: ColumnsSelectionDsl.(ColumnWithPath) -> AnyColumnReference): DataFrame = df.move(columns).under(column) public infix fun GroupClause.into(column: String): DataFrame = into(columnGroup().named(column)) public infix fun GroupClause.into(column: AnyColumnGroupAccessor): DataFrame = df.move(columns).under(column) public infix fun GroupClause.into(column: KProperty<*>): DataFrame = into(column.columnName) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/groupBy.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/groupBy.kt index e5f8032be..d686dd3d6 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/groupBy.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/groupBy.kt @@ -1,7 +1,7 @@ package org.jetbrains.kotlinx.dataframe.api +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.AnyFrame -import org.jetbrains.kotlinx.dataframe.Column import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow @@ -19,17 +19,17 @@ import kotlin.reflect.KProperty // region DataFrame public fun DataFrame.groupBy(moveToTop: Boolean = true, cols: ColumnsSelector): GroupBy = groupByImpl(moveToTop, cols) -public fun DataFrame.groupBy(cols: Iterable): GroupBy = groupBy { cols.toColumnSet() } +public fun DataFrame.groupBy(cols: Iterable): GroupBy = groupBy { cols.toColumnSet() } public fun DataFrame.groupBy(vararg cols: KProperty<*>): GroupBy = groupBy { cols.toColumns() } public fun DataFrame.groupBy(vararg cols: String): GroupBy = groupBy { cols.toColumns() } -public fun DataFrame.groupBy(vararg cols: Column, moveToTop: Boolean = true): GroupBy = groupBy(moveToTop) { cols.toColumns() } +public fun DataFrame.groupBy(vararg cols: AnyColumnReference, moveToTop: Boolean = true): GroupBy = groupBy(moveToTop) { cols.toColumns() } // endregion // region Pivot public fun Pivot.groupBy(moveToTop: Boolean = true, columns: ColumnsSelector): PivotGroupBy = (this as PivotImpl).toGroupedPivot(moveToTop, columns) -public fun Pivot.groupBy(vararg columns: Column): PivotGroupBy = groupBy { columns.toColumns() } +public fun Pivot.groupBy(vararg columns: AnyColumnReference): PivotGroupBy = groupBy { columns.toColumns() } public fun Pivot.groupBy(vararg columns: String): PivotGroupBy = groupBy { columns.toColumns() } public fun Pivot.groupBy(vararg columns: KProperty<*>): PivotGroupBy = groupBy { columns.toColumns() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/move.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/move.kt index 5a01944c5..90ec36cf3 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/move.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/move.kt @@ -1,7 +1,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.AnyColumnGroupAccessor -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnSelector import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame @@ -21,20 +21,20 @@ public fun DataFrame.move(vararg cols: KProperty): MoveClause public fun DataFrame.moveTo(newColumnIndex: Int, columns: ColumnsSelector): DataFrame = move(columns).to(newColumnIndex) public fun DataFrame.moveTo(newColumnIndex: Int, vararg columns: String): DataFrame = moveTo(newColumnIndex) { columns.toColumns() } -public fun DataFrame.moveTo(newColumnIndex: Int, vararg columns: Column): DataFrame = moveTo(newColumnIndex) { columns.toColumns() } +public fun DataFrame.moveTo(newColumnIndex: Int, vararg columns: AnyColumnReference): DataFrame = moveTo(newColumnIndex) { columns.toColumns() } public fun DataFrame.moveTo(newColumnIndex: Int, vararg columns: KProperty<*>): DataFrame = moveTo(newColumnIndex) { columns.toColumns() } public fun DataFrame.moveToLeft(columns: ColumnsSelector): DataFrame = move(columns).toLeft() public fun DataFrame.moveToLeft(vararg columns: String): DataFrame = moveToLeft { columns.toColumns() } -public fun DataFrame.moveToLeft(vararg columns: Column): DataFrame = moveToLeft { columns.toColumns() } +public fun DataFrame.moveToLeft(vararg columns: AnyColumnReference): DataFrame = moveToLeft { columns.toColumns() } public fun DataFrame.moveToLeft(vararg columns: KProperty<*>): DataFrame = moveToLeft { columns.toColumns() } public fun DataFrame.moveToRight(columns: ColumnsSelector): DataFrame = move(columns).toRight() public fun DataFrame.moveToRight(vararg columns: String): DataFrame = moveToRight { columns.toColumns() } -public fun DataFrame.moveToRight(vararg columns: Column): DataFrame = moveToRight { columns.toColumns() } +public fun DataFrame.moveToRight(vararg columns: AnyColumnReference): DataFrame = moveToRight { columns.toColumns() } public fun DataFrame.moveToRight(vararg columns: KProperty<*>): DataFrame = moveToRight { columns.toColumns() } -public fun MoveClause.into(column: ColumnsSelectionDsl.(ColumnWithPath) -> Column): DataFrame = moveImpl( +public fun MoveClause.into(column: ColumnsSelectionDsl.(ColumnWithPath) -> AnyColumnReference): DataFrame = moveImpl( under = false, column ) @@ -42,7 +42,7 @@ public fun MoveClause.into(column: ColumnsSelectionDsl.(ColumnWi public fun MoveClause.into(column: String): DataFrame = pathOf(column).let { path -> into { path } } public fun MoveClause.intoIndexed( - newPathExpression: ColumnsSelectionDsl.(ColumnWithPath, Int) -> Column + newPathExpression: ColumnsSelectionDsl.(ColumnWithPath, Int) -> AnyColumnReference ): DataFrame { var counter = 0 return into { col -> @@ -52,7 +52,7 @@ public fun MoveClause.intoIndexed( public fun MoveClause.under(column: String): DataFrame = pathOf(column).let { path -> under { path } } public fun MoveClause.under(column: AnyColumnGroupAccessor): DataFrame = column.path().let { path -> under { path } } -public fun MoveClause.under(column: ColumnsSelectionDsl.(ColumnWithPath) -> Column): DataFrame = moveImpl( +public fun MoveClause.under(column: ColumnsSelectionDsl.(ColumnWithPath) -> AnyColumnReference): DataFrame = moveImpl( under = true, column ) @@ -66,7 +66,7 @@ public fun MoveClause.toTop( public fun MoveClause.after(column: ColumnSelector): DataFrame = afterOrBefore(column, true) public fun MoveClause.after(column: String): DataFrame = after { column.toColumnAccessor() } -public fun MoveClause.after(column: Column): DataFrame = after { column } +public fun MoveClause.after(column: AnyColumnReference): DataFrame = after { column } public fun MoveClause.after(column: KProperty<*>): DataFrame = after { column.toColumnAccessor() } // TODO: implement 'before' 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 c4023430c..ed99ff907 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 @@ -1,6 +1,6 @@ package org.jetbrains.kotlinx.dataframe.api -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow @@ -41,17 +41,17 @@ public interface PivotDsl : ColumnsSelectionDsl { public fun DataFrame.pivot(inward: Boolean? = null, columns: PivotColumnsSelector): Pivot = PivotImpl(this, columns, inward) public fun DataFrame.pivot(vararg columns: String, inward: Boolean? = null): Pivot = pivot(inward) { columns.toColumns() } -public fun DataFrame.pivot(vararg columns: Column, inward: Boolean? = null): Pivot = pivot(inward) { columns.toColumns() } +public fun DataFrame.pivot(vararg columns: AnyColumnReference, inward: Boolean? = null): Pivot = pivot(inward) { columns.toColumns() } public fun DataFrame.pivot(vararg columns: KProperty<*>, inward: Boolean? = null): Pivot = pivot(inward) { columns.toColumns() } public fun DataFrame.pivotMatches(inward: Boolean = true, columns: ColumnsSelector): DataFrame = pivot(inward, columns).groupByOther().matches() public fun DataFrame.pivotMatches(vararg columns: String, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumns() } -public fun DataFrame.pivotMatches(vararg columns: Column, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumns() } +public fun DataFrame.pivotMatches(vararg columns: AnyColumnReference, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumns() } public fun DataFrame.pivotMatches(vararg columns: KProperty<*>, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumns() } public fun DataFrame.pivotCounts(inward: Boolean = true, columns: ColumnsSelector): DataFrame = pivot(inward, columns).groupByOther().count() public fun DataFrame.pivotCounts(vararg columns: String, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumns() } -public fun DataFrame.pivotCounts(vararg columns: Column, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumns() } +public fun DataFrame.pivotCounts(vararg columns: AnyColumnReference, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumns() } public fun DataFrame.pivotCounts(vararg columns: KProperty<*>, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumns() } // endregion @@ -59,18 +59,18 @@ public fun DataFrame.pivotCounts(vararg columns: KProperty<*>, inward: Bo // region GroupBy public fun GroupBy<*, G>.pivot(inward: Boolean = true, columns: ColumnsSelector): PivotGroupBy = PivotGroupByImpl(this, columns, inward) -public fun GroupBy<*, G>.pivot(vararg columns: Column, inward: Boolean = true): PivotGroupBy = pivot(inward) { columns.toColumns() } +public fun GroupBy<*, G>.pivot(vararg columns: AnyColumnReference, inward: Boolean = true): PivotGroupBy = pivot(inward) { columns.toColumns() } public fun GroupBy<*, G>.pivot(vararg columns: String, inward: Boolean = true): PivotGroupBy = pivot(inward) { columns.toColumns() } public fun GroupBy<*, G>.pivot(vararg columns: KProperty<*>, inward: Boolean = true): PivotGroupBy = pivot(inward) { columns.toColumns() } public fun GroupBy<*, G>.pivotMatches(inward: Boolean = true, columns: ColumnsSelector): DataFrame = pivot(inward, columns).matches() public fun GroupBy<*, G>.pivotMatches(vararg columns: String, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumns() } -public fun GroupBy<*, G>.pivotMatches(vararg columns: Column, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumns() } +public fun GroupBy<*, G>.pivotMatches(vararg columns: AnyColumnReference, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumns() } public fun GroupBy<*, G>.pivotMatches(vararg columns: KProperty<*>, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumns() } public fun GroupBy<*, G>.pivotCounts(inward: Boolean = true, columns: ColumnsSelector): DataFrame = pivot(inward, columns).count() public fun GroupBy<*, G>.pivotCounts(vararg columns: String, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumns() } -public fun GroupBy<*, G>.pivotCounts(vararg columns: Column, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumns() } +public fun GroupBy<*, G>.pivotCounts(vararg columns: AnyColumnReference, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumns() } public fun GroupBy<*, G>.pivotCounts(vararg columns: KProperty<*>, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumns() } // endregion @@ -80,17 +80,17 @@ public fun GroupBy<*, G>.pivotCounts(vararg columns: KProperty<*>, inward: B public fun AggregateGroupedDsl.pivot(inward: Boolean = true, columns: ColumnsSelector): PivotGroupBy = PivotInAggregateImpl(this, columns, inward) public fun AggregateGroupedDsl.pivot(vararg columns: String, inward: Boolean = true): PivotGroupBy = pivot(inward) { columns.toColumns() } -public fun AggregateGroupedDsl.pivot(vararg columns: Column, inward: Boolean = true): PivotGroupBy = pivot(inward) { columns.toColumns() } +public fun AggregateGroupedDsl.pivot(vararg columns: AnyColumnReference, inward: Boolean = true): PivotGroupBy = pivot(inward) { columns.toColumns() } public fun AggregateGroupedDsl.pivot(vararg columns: KProperty<*>, inward: Boolean = true): PivotGroupBy = pivot(inward) { columns.toColumns() } public fun AggregateGroupedDsl.pivotMatches(inward: Boolean = true, columns: ColumnsSelector): DataFrame = pivot(inward, columns).matches() public fun AggregateGroupedDsl.pivotMatches(vararg columns: String, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumns() } -public fun AggregateGroupedDsl.pivotMatches(vararg columns: Column, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumns() } +public fun AggregateGroupedDsl.pivotMatches(vararg columns: AnyColumnReference, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumns() } public fun AggregateGroupedDsl.pivotMatches(vararg columns: KProperty<*>, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumns() } public fun AggregateGroupedDsl.pivotCounts(inward: Boolean = true, columns: ColumnsSelector): DataFrame = pivot(inward, columns).matches() public fun AggregateGroupedDsl.pivotCounts(vararg columns: String, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumns() } -public fun AggregateGroupedDsl.pivotCounts(vararg columns: Column, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumns() } +public fun AggregateGroupedDsl.pivotCounts(vararg columns: AnyColumnReference, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumns() } public fun AggregateGroupedDsl.pivotCounts(vararg columns: KProperty<*>, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumns() } // endregion diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/remove.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/remove.kt index b252b7ed0..85226f1c3 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/remove.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/remove.kt @@ -1,6 +1,6 @@ package org.jetbrains.kotlinx.dataframe.api -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.impl.api.removeImpl @@ -13,12 +13,12 @@ import kotlin.reflect.KProperty public fun DataFrame.remove(columns: ColumnsSelector): DataFrame = removeImpl(allowMissingColumns = true, columns = columns).df public fun DataFrame.remove(vararg columns: KProperty<*>): DataFrame = remove { columns.toColumns() } public fun DataFrame.remove(vararg columns: String): DataFrame = remove { columns.toColumns() } -public fun DataFrame.remove(vararg columns: Column): DataFrame = remove { columns.toColumns() } -public fun DataFrame.remove(columns: Iterable): DataFrame = remove { columns.toColumnSet() } +public fun DataFrame.remove(vararg columns: AnyColumnReference): DataFrame = remove { columns.toColumns() } +public fun DataFrame.remove(columns: Iterable): DataFrame = remove { columns.toColumnSet() } public infix operator fun DataFrame.minus(columns: ColumnsSelector): DataFrame = remove(columns) public infix operator fun DataFrame.minus(column: String): DataFrame = remove(column) -public infix operator fun DataFrame.minus(column: Column): DataFrame = remove(column) -public infix operator fun DataFrame.minus(columns: Iterable): DataFrame = remove(columns) +public infix operator fun DataFrame.minus(column: AnyColumnReference): DataFrame = remove(column) +public infix operator fun DataFrame.minus(columns: Iterable): DataFrame = remove(columns) // endregion 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 5f9b8a8bb..e134fd9dd 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 @@ -1,6 +1,6 @@ package org.jetbrains.kotlinx.dataframe.api -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.impl.columnName @@ -13,9 +13,9 @@ import kotlin.reflect.KProperty public fun DataFrame.select(columns: ColumnsSelector): DataFrame = get(columns).toDataFrame().cast() public fun DataFrame.select(vararg columns: KProperty<*>): DataFrame = select(columns.map { it.columnName }) public fun DataFrame.select(vararg columns: String): DataFrame = select(columns.asIterable()) -public fun DataFrame.select(vararg columns: Column): DataFrame = select { columns.toColumns() } +public fun DataFrame.select(vararg columns: AnyColumnReference): DataFrame = select { columns.toColumns() } @JvmName("selectT") public fun DataFrame.select(columns: Iterable): DataFrame = columns.map { get(it) }.toDataFrame().cast() -public fun DataFrame.select(columns: Iterable): DataFrame = select { columns.toColumnSet() } +public fun DataFrame.select(columns: Iterable): DataFrame = select { columns.toColumnSet() } // endregion 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 6c79cf73a..943c94fa6 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 @@ -1,8 +1,8 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.AnyBaseCol +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.AnyFrame -import org.jetbrains.kotlinx.dataframe.Column import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame @@ -40,7 +40,7 @@ public fun DataFrame.read(vararg columns: String): DataFrame = unfold( public fun DataFrame.read(vararg columns: KProperty<*>): DataFrame = unfold(*columns) @Deprecated("Replaced with `unfold` operation.", ReplaceWith("this.unfold(*columns)"), DeprecationLevel.ERROR) -public fun DataFrame.read(vararg columns: Column): DataFrame = unfold(*columns) +public fun DataFrame.read(vararg columns: AnyColumnReference): DataFrame = unfold(*columns) @JvmName("toDataFrameT") public fun Iterable>.toDataFrame(): DataFrame { diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/unfold.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/unfold.kt index 54f59bf95..1ad347213 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/unfold.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/unfold.kt @@ -1,7 +1,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.AnyCol -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame @@ -25,4 +25,4 @@ public inline fun DataColumn.unfold(): AnyCol = public fun DataFrame.unfold(columns: ColumnsSelector): DataFrame = replace(columns).with { it.unfold() } public fun DataFrame.unfold(vararg columns: String): DataFrame = unfold { columns.toColumns() } public fun DataFrame.unfold(vararg columns: KProperty<*>): DataFrame = unfold { columns.toColumns() } -public fun DataFrame.unfold(vararg columns: Column): DataFrame = unfold { columns.toColumns() } +public fun DataFrame.unfold(vararg columns: AnyColumnReference): DataFrame = unfold { columns.toColumns() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ungroup.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ungroup.kt index 65e0f820c..7633687ba 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ungroup.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ungroup.kt @@ -1,6 +1,6 @@ package org.jetbrains.kotlinx.dataframe.api -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.impl.columns.toColumns @@ -15,7 +15,7 @@ public fun DataFrame.ungroup(columns: ColumnsSelector): DataFram } public fun DataFrame.ungroup(vararg columns: String): DataFrame = ungroup { columns.toColumns() } -public fun DataFrame.ungroup(vararg columns: Column): DataFrame = ungroup { columns.toColumns() } +public fun DataFrame.ungroup(vararg columns: AnyColumnReference): DataFrame = ungroup { columns.toColumns() } public fun DataFrame.ungroup(vararg columns: KProperty<*>): DataFrame = ungroup { columns.toColumns() } // endregion 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 7de0675a8..fcfef0e04 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 @@ -1,6 +1,6 @@ package org.jetbrains.kotlinx.dataframe.api -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame @@ -70,7 +70,7 @@ public fun DataFrame.valueCounts( resultColumn: String = defaultCountColumnName ): DataFrame = valueCounts(sort, ascending, dropNA, resultColumn) { columns.toColumns() } public fun DataFrame.valueCounts( - vararg columns: Column, + vararg columns: AnyColumnReference, sort: Boolean = true, ascending: Boolean = false, dropNA: 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 417487f73..a6e949a9e 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 @@ -1,6 +1,6 @@ package org.jetbrains.kotlinx.dataframe.api -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow @@ -24,7 +24,7 @@ public fun DataFrame.valuesNotNull(byRow: Boolean = false): Sequence // region GroupBy -public fun Grouped.values(vararg columns: Column, dropNA: Boolean = false, distinct: Boolean = false): DataFrame = values(dropNA, distinct) { columns.toColumns() } +public fun Grouped.values(vararg columns: AnyColumnReference, dropNA: Boolean = false, distinct: Boolean = false): DataFrame = values(dropNA, distinct) { columns.toColumns() } public fun Grouped.values(vararg columns: String, dropNA: Boolean = false, distinct: Boolean = false): DataFrame = values(dropNA, distinct) { columns.toColumns() } public fun Grouped.values( dropNA: Boolean = false, @@ -40,7 +40,7 @@ public fun Grouped.values(dropNA: Boolean = false, distinct: Boolean = fa public fun ReducedGroupBy.values(): DataFrame = values(groupBy.remainingColumnsSelector()) public fun ReducedGroupBy.values( - vararg columns: Column + vararg columns: AnyColumnReference ): DataFrame = values { columns.toColumns() } public fun ReducedGroupBy.values( @@ -66,7 +66,7 @@ public fun Pivot.values( columns: ColumnsForAggregateSelector ): DataRow = delegate { values(dropNA, distinct, separate, columns) } public fun Pivot.values( - vararg columns: Column, + vararg columns: AnyColumnReference, dropNA: Boolean = false, distinct: Boolean = false, separate: Boolean = false @@ -95,7 +95,7 @@ public fun ReducedPivot.values( ): DataRow = pivot.delegate { reduce(reducer).values(separate = separate) } public fun ReducedPivot.values( - vararg columns: Column, + vararg columns: AnyColumnReference, separate: Boolean = false ): DataRow = values(separate) { columns.toColumns() } @@ -121,7 +121,7 @@ public fun ReducedPivot.values( public fun PivotGroupBy.values(dropNA: Boolean = false, distinct: Boolean = false, separate: Boolean = false): DataFrame = values(dropNA, distinct, separate, remainingColumnsSelector()) public fun PivotGroupBy.values( - vararg columns: Column, + vararg columns: AnyColumnReference, dropNA: Boolean = false, distinct: Boolean = false, separate: Boolean = false @@ -155,7 +155,7 @@ public fun ReducedPivotGroupBy.values( ): DataFrame = values(separate, pivot.remainingColumnsSelector()) public fun ReducedPivotGroupBy.values( - vararg columns: Column, + vararg columns: AnyColumnReference, separate: Boolean = false ): DataFrame = values(separate) { columns.toColumns() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/with.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/with.kt index 7b5942b83..04ae27ae3 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/with.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/with.kt @@ -1,6 +1,6 @@ package org.jetbrains.kotlinx.dataframe.api -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowExpression @@ -37,7 +37,7 @@ public inline fun ReducedPivotGroupBy.with(noinline expression return pivot.aggregate { val value = reducer(this)?.let { val value = expression(it, it) - if (value is Column) it[value] + if (value is AnyColumnReference) it[value] else value } internal().yield(emptyPath(), value, type) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/aggregation/aggregations.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/aggregation/aggregations.kt index 925a70fdd..f18c558ca 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/aggregation/aggregations.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/aggregation/aggregations.kt @@ -1,6 +1,6 @@ package org.jetbrains.kotlinx.dataframe.impl.aggregation -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowExpression @@ -90,7 +90,7 @@ internal fun AggregateInternalDsl.columnValues( internal fun AggregateInternalDsl.withExpr(type: KType, path: ColumnPath, expression: RowExpression) { val values = df.rows().map { val value = expression(it, it) - if (value is Column) it[value] + if (value is AnyColumnReference) it[value] else value } yieldOneOrMany(path, values, type) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/move.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/move.kt index 0e51a7362..e70c945ef 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/move.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/move.kt @@ -1,6 +1,6 @@ package org.jetbrains.kotlinx.dataframe.impl.api -import org.jetbrains.kotlinx.dataframe.Column +import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnSelector import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame @@ -43,7 +43,7 @@ internal fun MoveClause.afterOrBefore(column: ColumnSelector, internal fun MoveClause.moveImpl( under: Boolean = false, - newPathExpression: ColumnsSelectionDsl.(ColumnWithPath) -> Column + newPathExpression: ColumnsSelectionDsl.(ColumnWithPath) -> AnyColumnReference ): DataFrame { val receiver = object : DataFrameReceiver(df, UnresolvedColumnsPolicy.Fail), ColumnsSelectionDsl {} val removeResult = df.removeImpl(columns = columns)