diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsContainer.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsContainer.kt index 85af9ee021..16738d4d48 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsContainer.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsContainer.kt @@ -1,5 +1,6 @@ package org.jetbrains.kotlinx.dataframe +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.api.ColumnSelectionDsl import org.jetbrains.kotlinx.dataframe.api.asColumnGroup import org.jetbrains.kotlinx.dataframe.api.cast @@ -42,8 +43,10 @@ public interface ColumnsContainer { public fun getColumnOrNull(index: Int): AnyCol? + @AccessApiOverload public fun getColumnOrNull(column: ColumnReference): DataColumn? + @AccessApiOverload public fun getColumnOrNull(column: KProperty): DataColumn? public fun getColumnOrNull(path: ColumnPath): AnyCol? @@ -58,23 +61,32 @@ public interface ColumnsContainer { public operator fun get(columnPath: ColumnPath): AnyCol = getColumn(columnPath) + @AccessApiOverload public operator fun get(column: DataColumn): DataColumn = getColumn(column.name()).cast() + @AccessApiOverload public operator fun get(column: DataColumn>): ColumnGroup = getColumn(column) + @AccessApiOverload public operator fun get(column: DataColumn>): FrameColumn = getColumn(column) + @AccessApiOverload public operator fun get(column: ColumnReference): DataColumn = getColumn(column) + @AccessApiOverload public operator fun get(column: ColumnReference>): ColumnGroup = getColumn(column) + @AccessApiOverload public operator fun get(column: ColumnReference>): FrameColumn = getColumn(column) + @AccessApiOverload public operator fun get(column: KProperty): DataColumn = get(column.columnName).cast() + @AccessApiOverload public operator fun get(column: KProperty>): ColumnGroup = get(column.columnName).asColumnGroup().cast() + @AccessApiOverload public operator fun get(column: KProperty>): FrameColumn = get(column.columnName).asAnyFrameColumn().castFrameColumn() 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 c997fbffb4..63b1d0c834 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataFrame.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataFrame.kt @@ -2,6 +2,7 @@ package org.jetbrains.kotlinx.dataframe import org.jetbrains.kotlinx.dataframe.aggregation.Aggregatable import org.jetbrains.kotlinx.dataframe.aggregation.AggregateGroupedBody +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.HasSchema import org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl import org.jetbrains.kotlinx.dataframe.api.add @@ -116,6 +117,7 @@ public interface DataFrame : */ public operator fun DataFrame.get(columns: ColumnsSelector): List> = this.get(columns) +@AccessApiOverload public operator fun DataFrame.get(first: AnyColumnReference, vararg other: AnyColumnReference): DataFrame = select { (listOf(first) + other).toColumnSet() } 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 68399d748a..4eb543c244 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataRow.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataRow.kt @@ -1,5 +1,6 @@ package org.jetbrains.kotlinx.dataframe +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.api.next import org.jetbrains.kotlinx.dataframe.api.prev import org.jetbrains.kotlinx.dataframe.columns.ColumnKind @@ -31,6 +32,7 @@ public interface DataRow { public operator fun get(columns: List>): List = columns.map { get(it) } + @AccessApiOverload public operator fun get(property: KProperty): R = get(property.columnName) as R public operator fun get(first: AnyColumnReference, vararg other: AnyColumnReference): DataRow = @@ -66,6 +68,7 @@ public interface DataRow { public fun getOrNull(name: String): Any? + @AccessApiOverload public fun getValueOrNull(column: ColumnReference): R? // endregion @@ -74,6 +77,7 @@ public interface DataRow { public operator fun String.get(vararg path: String): ColumnPath = ColumnPath(listOf(this) + path) + @AccessApiOverload public operator fun ColumnReference.invoke(): R = get(this) public operator fun String.invoke(): R = this@DataRow[this@invoke] as R 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 c5322aa2ef..4e13bbc22a 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 @@ -8,6 +8,7 @@ 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.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -63,12 +64,15 @@ public fun ColumnsContainer.getColumnGroup(columnPath: ColumnPath): Colum public fun ColumnsContainer.getColumn(name: String): AnyCol = getColumnOrNull(name) ?: throw IllegalArgumentException("Column not found: '$name'") +@AccessApiOverload public fun ColumnsContainer.getColumn(column: ColumnReference>): FrameColumn = getColumnOrNull(column)?.asFrameColumn() ?: throw IllegalArgumentException("FrameColumn not found: '$column'") +@AccessApiOverload public fun ColumnsContainer.getColumn(column: ColumnReference>): ColumnGroup = getColumnOrNull(column)?.asColumnGroup() ?: throw IllegalArgumentException("ColumnGroup not found: '$column'") +@AccessApiOverload public fun ColumnsContainer.getColumn(column: ColumnReference): DataColumn = getColumnOrNull(column) ?: throw IllegalArgumentException("Column not found: '$column'") @@ -89,9 +93,11 @@ public fun ColumnsContainer.getColumnGroup(index: Int): ColumnGroup<*> = public fun ColumnsContainer.getColumnGroup(name: String): ColumnGroup<*> = getColumn(name).asColumnGroup() +@AccessApiOverload public fun ColumnsContainer.getColumnGroup(column: KProperty<*>): ColumnGroup<*> = getColumnGroup(column.columnName) +@AccessApiOverload public fun ColumnsContainer.getColumnGroup(column: ColumnReference>): ColumnGroup = getColumn(column) @@ -105,6 +111,7 @@ public fun ColumnsContainer.getColumnGroup(column: ColumnSelector ColumnsContainer.getColumnGroupOrNull(name: String): ColumnGroup<*>? = getColumnOrNull(name)?.asColumnGroup() +@AccessApiOverload public fun ColumnsContainer.getColumnGroupOrNull(column: KProperty<*>): ColumnGroup<*>? = getColumnGroupOrNull(column.columnName) @@ -112,12 +119,16 @@ public fun ColumnsContainer.getColumnGroupOrNull(column: KProperty<*>): C // region containsColumn +@AccessApiOverload public fun ColumnsContainer<*>.containsColumn(column: ColumnReference): Boolean = getColumnOrNull(column) != null +@AccessApiOverload public fun ColumnsContainer<*>.containsColumn(column: KProperty<*>): Boolean = containsColumn(column.columnName) +@AccessApiOverload public operator fun ColumnsContainer<*>.contains(column: AnyColumnReference): Boolean = containsColumn(column) +@AccessApiOverload 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 179caa7101..8a88448072 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 @@ -7,6 +7,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.annotations.DataSchema import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.impl.columnName @@ -60,10 +61,12 @@ public fun AnyRow.getValue(columnName: String): T = get(columnName) as T public fun AnyRow.getValue(column: ColumnReference): T = get(column) +@AccessApiOverload public fun AnyRow.getValue(column: KProperty): T = get(column) public fun AnyRow.getValueOrNull(columnName: String): T? = getOrNull(columnName) as T? +@AccessApiOverload public fun AnyRow.getValueOrNull(column: KProperty): T? = getValueOrNull(column.columnName) // endregion @@ -74,10 +77,12 @@ public fun AnyRow.containsKey(columnName: String): Boolean = owner.containsColum public fun AnyRow.containsKey(column: AnyColumnReference): Boolean = owner.containsColumn(column) +@AccessApiOverload public fun AnyRow.containsKey(column: KProperty<*>): Boolean = owner.containsColumn(column) public operator fun AnyRow.contains(column: AnyColumnReference): Boolean = containsKey(column) +@AccessApiOverload 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 9f093ae247..3312835cd1 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 @@ -7,6 +7,7 @@ import org.jetbrains.kotlinx.dataframe.AnyRow 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.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.api.DropNA.DropNASelectingOptions @@ -85,6 +86,7 @@ public fun DataFrame.fillNulls(vararg columns: String): Update = * @include [SelectingColumns.KProperties.WithExample] {@include [SetFillNullsOperationArg]} * @include [Update.KPropertiesParam] */ +@AccessApiOverload public fun DataFrame.fillNulls(vararg columns: KProperty): Update = fillNulls { columns.toColumnSet() } @@ -93,6 +95,7 @@ public fun DataFrame.fillNulls(vararg columns: KProperty): Update DataFrame.fillNulls(vararg columns: ColumnReference): Update = fillNulls { columns.toColumnSet() } @@ -176,6 +179,7 @@ public fun DataFrame.fillNaNs(vararg columns: String): Update = * @include [SelectingColumns.KProperties.WithExample] {@include [SetFillNaNsOperationArg]} * @include [Update.KPropertiesParam] */ +@AccessApiOverload public fun DataFrame.fillNaNs(vararg columns: KProperty): Update = fillNaNs { columns.toColumnSet() } /** @@ -183,6 +187,7 @@ public fun DataFrame.fillNaNs(vararg columns: KProperty): Update DataFrame.fillNaNs(vararg columns: ColumnReference): Update = fillNaNs { columns.toColumnSet() } @@ -246,6 +251,7 @@ public fun DataFrame.fillNA(vararg columns: String): Update = fi * @include [SelectingColumns.KProperties.WithExample] {@include [SetFillNAOperationArg]} * @include [Update.KPropertiesParam] */ +@AccessApiOverload public fun DataFrame.fillNA(vararg columns: KProperty): Update = fillNA { columns.toColumnSet() } /** @@ -253,6 +259,7 @@ public fun DataFrame.fillNA(vararg columns: KProperty): Update DataFrame.fillNA(vararg columns: ColumnReference): Update = fillNA { columns.toColumnSet() } @@ -348,6 +355,7 @@ public fun DataFrame.dropNulls(whereAllNull: Boolean = false): DataFrame< * @include [DropNulls.WhereAllNullParam] * @include [DropKPropertiesParam] */ +@AccessApiOverload public fun DataFrame.dropNulls(vararg columns: KProperty<*>, whereAllNull: Boolean = false): DataFrame = dropNulls(whereAllNull) { columns.toColumnSet() } @@ -368,6 +376,7 @@ public fun DataFrame.dropNulls(vararg columns: String, whereAllNull: Bool * @include [DropNulls.WhereAllNullParam] * @include [DropColumnAccessorsParam] */ +@AccessApiOverload public fun DataFrame.dropNulls(vararg columns: AnyColumnReference, whereAllNull: Boolean = false): DataFrame = dropNulls(whereAllNull) { columns.toColumnSet() } @@ -445,6 +454,7 @@ public fun DataFrame.dropNA(whereAllNA: Boolean = false, columns: Columns * @include [DropNA.WhereAllNAParam] * @include [DropKPropertiesParam] */ +@AccessApiOverload public fun DataFrame.dropNA(vararg columns: KProperty<*>, whereAllNA: Boolean = false): DataFrame = dropNA(whereAllNA) { columns.toColumnSet() } @@ -465,6 +475,7 @@ public fun DataFrame.dropNA(vararg columns: String, whereAllNA: Boolean = * @include [DropNA.WhereAllNAParam] * @include [DropColumnAccessorsParam] */ +@AccessApiOverload public fun DataFrame.dropNA(vararg columns: AnyColumnReference, whereAllNA: Boolean = false): DataFrame = dropNA(whereAllNA) { columns.toColumnSet() } @@ -552,6 +563,7 @@ public fun DataFrame.dropNaNs(whereAllNaN: Boolean = false, columns: Colu * @include [DropNaNs.WhereAllNaNParam] * @include [DropKPropertiesParam] */ +@AccessApiOverload public fun DataFrame.dropNaNs(vararg columns: KProperty<*>, whereAllNaN: Boolean = false): DataFrame = dropNaNs(whereAllNaN) { columns.toColumnSet() } @@ -572,6 +584,7 @@ public fun DataFrame.dropNaNs(vararg columns: String, whereAllNaN: Boolea * @include [DropNaNs.WhereAllNaNParam] * @include [DropColumnAccessorsParam] */ +@AccessApiOverload public fun DataFrame.dropNaNs(vararg columns: AnyColumnReference, whereAllNaN: Boolean = false): DataFrame = dropNaNs(whereAllNaN) { columns.toColumnSet() } 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 50cc00d035..16033ee92a 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 @@ -12,6 +12,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowExpression import org.jetbrains.kotlinx.dataframe.Selector +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.BaseColumn @@ -131,12 +132,14 @@ public inline fun DataFrame.add( noinline expression: AddExpression, ): DataFrame = (this + mapToColumn(name, infer, expression)) +@AccessApiOverload public inline fun DataFrame.add( property: KProperty, infer: Infer = Infer.Nulls, noinline expression: AddExpression, ): DataFrame = (this + mapToColumn(property, infer, expression)) +@AccessApiOverload public inline fun DataFrame.add( column: ColumnAccessor, infer: Infer = Infer.Nulls, @@ -188,30 +191,38 @@ public class AddDsl( add(this, Infer.Nulls, expression) // TODO: use path instead of name + @AccessApiOverload public inline infix fun ColumnAccessor.from(noinline expression: RowExpression): Boolean = name().from(expression) + @AccessApiOverload public inline infix fun KProperty.from(noinline expression: RowExpression): Boolean = add(name, Infer.Nulls, expression) public infix fun String.from(column: AnyColumnReference): Boolean = add(column.rename(this)) + @AccessApiOverload public inline infix fun ColumnAccessor.from(column: ColumnReference): Boolean = name() from column + @AccessApiOverload public inline infix fun KProperty.from(column: ColumnReference): Boolean = name from column @Interpretable("Into") public infix fun AnyColumnReference.into(name: String): Boolean = add(rename(name)) + @AccessApiOverload public infix fun ColumnReference.into(column: ColumnAccessor): Boolean = into(column.name()) + @AccessApiOverload public infix fun ColumnReference.into(column: KProperty): Boolean = into(column.name) @Interpretable("AddDslStringInvoke") public operator fun String.invoke(body: AddDsl.() -> Unit): Unit = group(this, body) + @AccessApiOverload public infix fun AnyColumnGroupAccessor.from(body: AddDsl.() -> Unit): Unit = group(this, body) + @AccessApiOverload public fun group(column: AnyColumnGroupAccessor, body: AddDsl.() -> Unit): Unit = group(column.name(), body) public fun group(name: String, body: AddDsl.() -> Unit) { @@ -224,6 +235,7 @@ public class AddDsl( public infix fun AddGroup.into(groupName: String): Unit = group(groupName, body) + @AccessApiOverload public infix fun AddGroup.into(column: AnyColumnGroupAccessor): Unit = into(column.name()) } @@ -241,6 +253,7 @@ public inline fun GroupBy.add( noinline expression: RowExpression, ): GroupBy = updateGroups { add(name, infer, expression) } +@AccessApiOverload public inline fun GroupBy.add( column: ColumnAccessor, infer: Infer = Infer.Nulls, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/addId.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/addId.kt index d29f697ab3..6ba09a8d04 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/addId.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/addId.kt @@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.AnyCol import org.jetbrains.kotlinx.dataframe.AnyFrame import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor @@ -15,6 +16,7 @@ public fun AnyCol.addId(columnName: String = "id"): AnyFrame = toDataFrame().add // region DataFrame +@AccessApiOverload public fun DataFrame.addId(column: ColumnAccessor): DataFrame = insert(column) { index() }.at(0) @Refine diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/and.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/and.kt index b5e744cb8b..dea6d7eeb2 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/and.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/and.kt @@ -2,6 +2,7 @@ package org.jetbrains.kotlinx.dataframe.api 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.Interpretable import org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.Grammar import org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.Grammar.InfixName @@ -125,6 +126,7 @@ public interface AndColumnsSelectionDsl { public infix fun ColumnsResolver.and(other: String): ColumnSet<*> = this and other.toColumnAccessor() /** @include [ColumnsResolverAndDocs] {@set [ColumnsResolverAndDocs.Argument] `Type::colB`} */ + @AccessApiOverload public infix fun ColumnsResolver.and(other: KProperty): ColumnSet = this and other.toColumnAccessor() // endregion @@ -152,6 +154,7 @@ public interface AndColumnsSelectionDsl { public infix fun String.and(other: String): ColumnSet<*> = toColumnAccessor() and other.toColumnAccessor() /** @include [StringAndDocs] {@set [StringAndDocs.Argument] `Type::colB`} */ + @AccessApiOverload public infix fun String.and(other: KProperty): ColumnSet<*> = toColumnAccessor() and other // endregion @@ -180,6 +183,7 @@ public interface AndColumnsSelectionDsl { public infix fun KProperty.and(other: String): ColumnSet<*> = toColumnAccessor() and other /** @include [KPropertyAndDocs] {@set [KPropertyAndDocs.Argument] `Type::colB`} */ + @AccessApiOverload public infix fun KProperty.and(other: KProperty): ColumnSet = toColumnAccessor() and other.toColumnAccessor() diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt index 7eed1e126b..430c64e85f 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowColumnExpression import org.jetbrains.kotlinx.dataframe.RowValueExpression +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.HasSchema import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine @@ -50,14 +51,17 @@ import kotlin.reflect.typeOf @Interpretable("Convert0") public fun DataFrame.convert(columns: ColumnsSelector): Convert = Convert(this, columns) +@AccessApiOverload public fun DataFrame.convert(vararg columns: KProperty): Convert = convert { columns.toColumnSet() } @Interpretable("Convert2") public fun DataFrame.convert(vararg columns: String): Convert = convert { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.convert(vararg columns: ColumnReference): Convert = convert { columns.toColumnSet() } +@AccessApiOverload public inline fun DataFrame.convert( firstCol: ColumnReference, vararg cols: ColumnReference, @@ -65,6 +69,7 @@ public inline fun DataFrame.convert( noinline expression: RowValueExpression, ): DataFrame = convert(*headPlusArray(firstCol, cols)).with(infer, expression) +@AccessApiOverload public inline fun DataFrame.convert( firstCol: KProperty, vararg cols: KProperty, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/corr.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/corr.kt index ef84168c97..754a93c76e 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/corr.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/corr.kt @@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.AnyCol 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.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.toColumnSet import org.jetbrains.kotlinx.dataframe.impl.api.corrImpl @@ -21,17 +22,21 @@ public fun DataFrame.corr(columns: ColumnsSelector): Corr public fun DataFrame.corr(vararg columns: String): Corr = corr { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.corr(vararg columns: KProperty): Corr = corr { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.corr(vararg columns: ColumnReference): Corr = corr { columns.toColumnSet() } public fun Corr.with(otherColumns: ColumnsSelector): DataFrame = corrImpl(otherColumns) public fun Corr.with(vararg otherColumns: String): DataFrame = with { otherColumns.toColumnSet() } +@AccessApiOverload public fun Corr.with(vararg otherColumns: KProperty): DataFrame = with { otherColumns.toColumnSet() } +@AccessApiOverload public fun Corr.with(vararg otherColumns: ColumnReference): DataFrame = with { otherColumns.toColumnSet() } 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 099107f9a1..c2be71aecc 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 @@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.api.DistinctColumnsSelectionDsl.Grammar import org.jetbrains.kotlinx.dataframe.api.DistinctColumnsSelectionDsl.Grammar.ColumnSetName import org.jetbrains.kotlinx.dataframe.columns.ColumnSet @@ -21,6 +22,7 @@ public fun DataFrame.distinct(): DataFrame = distinctBy { all() } public fun DataFrame.distinct(columns: ColumnsSelector): DataFrame = select(columns).distinct() +@AccessApiOverload public fun DataFrame.distinct(vararg columns: KProperty<*>): DataFrame = distinct { val set = columns.toColumnSet() @@ -29,14 +31,17 @@ public fun DataFrame.distinct(vararg columns: KProperty<*>): DataFrame public fun DataFrame.distinct(vararg columns: String): DataFrame = distinct { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.distinct(vararg columns: AnyColumnReference): DataFrame = distinct { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.distinctBy(vararg columns: KProperty<*>): DataFrame = distinctBy { columns.toColumnSet() } public fun DataFrame.distinctBy(vararg columns: String): DataFrame = distinctBy { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.distinctBy(vararg columns: AnyColumnReference): DataFrame = distinctBy { columns.toColumnSet() } @@ -51,7 +56,7 @@ public fun DataFrame.distinctBy(columns: ColumnsSelector): DataF // region ColumnsSelectionDsl /** - * ## Distinct {@include [ColumnsSelectionDslLink]} + * ##### Distinct {@include [ColumnsSelectionDslLink]} * * See [Grammar] for all functions in this interface. */ diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/explode.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/explode.kt index 926b8a723f..45dab0c873 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/explode.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/explode.kt @@ -4,6 +4,7 @@ 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.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup @@ -25,9 +26,11 @@ public fun DataFrame.explode( public fun DataFrame.explode(vararg columns: String, dropEmpty: Boolean = true): DataFrame = explode(dropEmpty) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.explode(vararg columns: ColumnReference, dropEmpty: Boolean = true): DataFrame = explode(dropEmpty) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.explode(vararg columns: KProperty, dropEmpty: Boolean = true): DataFrame = explode(dropEmpty) { columns.toColumnSet() } @@ -43,9 +46,11 @@ public fun DataRow.explode( public fun DataRow.explode(vararg columns: String, dropEmpty: Boolean = true): DataFrame = explode(dropEmpty) { columns.toColumnSet() } +@AccessApiOverload public fun DataRow.explode(vararg columns: ColumnReference, dropEmpty: Boolean = true): DataFrame = explode(dropEmpty) { columns.toColumnSet() } +@AccessApiOverload public fun DataRow.explode(vararg columns: KProperty, dropEmpty: Boolean = true): DataFrame = explode(dropEmpty) { columns.toColumnSet() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/filter.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/filter.kt index 4b2c017675..c0e10907a7 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/filter.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/filter.kt @@ -7,6 +7,7 @@ import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.Predicate import org.jetbrains.kotlinx.dataframe.RowFilter +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.api.FilterColumnsSelectionDsl.Grammar.ColumnSetName import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -44,8 +45,10 @@ public fun DataFrame.filterBy(column: ColumnSelector): DataFr public fun DataFrame.filterBy(column: String): DataFrame = filterBy { column.toColumnOf() } +@AccessApiOverload public fun DataFrame.filterBy(column: ColumnReference): DataFrame = filterBy { column } +@AccessApiOverload public fun DataFrame.filterBy(column: KProperty): DataFrame = filterBy { column.toColumnAccessor() } // endregion diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/flatten.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/flatten.kt index 7a9ede21de..95d3407a0a 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/flatten.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/flatten.kt @@ -2,6 +2,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -30,12 +31,14 @@ public fun DataFrame.flatten( separator: String = "_", ): DataFrame = flatten(keepParentNameForColumns, separator) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.flatten( vararg columns: ColumnReference, keepParentNameForColumns: Boolean = false, separator: String = "_", ): DataFrame = flatten(keepParentNameForColumns, separator) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.flatten( vararg columns: KProperty, keepParentNameForColumns: Boolean = false, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/format.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/format.kt index 9c2465800d..c0813d101d 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/format.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/format.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.RowValueFilter +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.MergedAttributes @@ -26,9 +27,11 @@ public fun DataFrame.format(columns: ColumnsSelector): FormatCla public fun DataFrame.format(vararg columns: String): FormatClause = format { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.format(vararg columns: ColumnReference): FormatClause = format { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.format(vararg columns: KProperty): FormatClause = format { columns.toColumnSet() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/gather.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/gather.kt index 52446cbd10..3c23bf6512 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/gather.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/gather.kt @@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.RowValueFilter +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.toColumnSet @@ -27,9 +28,11 @@ public fun DataFrame.gather(selector: ColumnsSelector): Gather DataFrame.gather(vararg columns: String): Gather = gather { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.gather(vararg columns: ColumnReference): Gather = gather { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.gather(vararg columns: KProperty): Gather = gather { columns.toColumnSet() } @@ -76,6 +79,7 @@ public fun Gather.into( valueColumn: ColumnAccessor, ): DataFrame = into(keyColumn.name(), valueColumn.name) +@AccessApiOverload public fun Gather.into(keyColumn: KProperty, valueColumn: KProperty): DataFrame = into(keyColumn.columnName, valueColumn.columnName) @@ -85,9 +89,11 @@ public fun Gather.into(keyColumn: KProperty, valueCo public fun Gather.keysInto(keyColumn: String): DataFrame = gatherImpl(keyColumn, null) +@AccessApiOverload public fun Gather.keysInto(keyColumn: ColumnAccessor): DataFrame = keysInto(keyColumn.name()) +@AccessApiOverload public fun Gather.keysInto(keyColumn: KProperty): DataFrame = keysInto(keyColumn.columnName) @@ -97,9 +103,11 @@ public fun Gather.keysInto(keyColumn: KProperty): Da public fun Gather.valuesInto(valueColumn: String): DataFrame = gatherImpl(null, valueColumn) +@AccessApiOverload public fun Gather.valuesInto(valueColumn: ColumnAccessor): DataFrame = valuesInto(valueColumn.name()) +@AccessApiOverload public fun Gather.valuesInto(valueColumn: KProperty): DataFrame = valuesInto(valueColumn.columnName) 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 9bd4c1602c..a98ba0b6f5 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 @@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.AnyColumnGroupAccessor import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath @@ -19,9 +20,11 @@ public fun DataFrame.group(columns: ColumnsSelector): GroupClaus public fun DataFrame.group(vararg columns: String): GroupClause = group { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.group(vararg columns: AnyColumnReference): GroupClause = group { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.group(vararg columns: KProperty<*>): GroupClause = group { columns.toColumnSet() } // endregion @@ -49,8 +52,10 @@ public fun GroupClause.into( @Interpretable("Into0") public fun GroupClause.into(column: String): DataFrame = into(columnGroup().named(column)) +@AccessApiOverload public fun GroupClause.into(column: AnyColumnGroupAccessor): DataFrame = df.move(columns).under(column) +@AccessApiOverload public fun GroupClause.into(column: KProperty<*>): DataFrame = into(column.columnName) // endregion 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 4067b6b4fd..eb5be20565 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 @@ -7,6 +7,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.Selector import org.jetbrains.kotlinx.dataframe.aggregation.Aggregatable +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.FrameColumn @@ -33,10 +34,12 @@ import kotlin.reflect.KProperty public fun DataFrame.groupBy(moveToTop: Boolean = true, cols: ColumnsSelector): GroupBy = groupByImpl(moveToTop, cols) +@AccessApiOverload public fun DataFrame.groupBy(vararg cols: KProperty<*>): GroupBy = groupBy { cols.toColumnSet() } public fun DataFrame.groupBy(vararg cols: String): GroupBy = groupBy { cols.toColumnSet() } +@AccessApiOverload public fun DataFrame.groupBy(vararg cols: AnyColumnReference, moveToTop: Boolean = true): GroupBy = groupBy(moveToTop) { cols.toColumnSet() } @@ -47,10 +50,12 @@ public fun DataFrame.groupBy(vararg cols: AnyColumnReference, moveToTop: public fun Pivot.groupBy(moveToTop: Boolean = true, columns: ColumnsSelector): PivotGroupBy = (this as PivotImpl).toGroupedPivot(moveToTop, columns) +@AccessApiOverload public fun Pivot.groupBy(vararg columns: AnyColumnReference): PivotGroupBy = groupBy { columns.toColumnSet() } public fun Pivot.groupBy(vararg columns: String): PivotGroupBy = groupBy { columns.toColumnSet() } +@AccessApiOverload public fun Pivot.groupBy(vararg columns: KProperty<*>): PivotGroupBy = groupBy { columns.toColumnSet() } public fun Pivot.groupByOther(): PivotGroupBy { diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/implode.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/implode.kt index fac6243b91..fc28de0d57 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/implode.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/implode.kt @@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.ColumnsSelector 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.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.toColumnSet import org.jetbrains.kotlinx.dataframe.impl.api.implodeImpl @@ -18,9 +19,11 @@ public fun DataFrame.implode(dropNA: Boolean = false, columns: Columns public fun DataFrame.implode(vararg columns: String, dropNA: Boolean = false): DataFrame = implode(dropNA) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.implode(vararg columns: ColumnReference, dropNA: Boolean = false): DataFrame = implode(dropNA) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.implode(vararg columns: KProperty, dropNA: Boolean = false): DataFrame = implode(dropNA) { columns.toColumnSet() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/inferType.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/inferType.kt index 140b6b3a61..87759bc5c8 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/inferType.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/inferType.kt @@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.AnyCol 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.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.TypeSuggestion import org.jetbrains.kotlinx.dataframe.columns.toColumnSet @@ -27,9 +28,11 @@ public fun DataFrame.inferType(columns: ColumnsSelector): DataFrame public fun DataFrame.inferType(vararg columns: String): DataFrame = inferType { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.inferType(vararg columns: ColumnReference<*>): DataFrame = inferType { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.inferType(vararg columns: KProperty<*>): DataFrame = inferType { columns.toColumnSet() } // endregion 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 f0f5886b7d..fa67fd3b74 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 @@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.ColumnSelector import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.RowExpression +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor @@ -65,6 +66,7 @@ public fun InsertClause.under(column: ColumnAccessor<*>): DataFrame = @Refine @Interpretable("Under3") +@AccessApiOverload public fun InsertClause.under(column: KProperty<*>): DataFrame = under(column.columnName) @Refine @@ -81,6 +83,7 @@ public fun InsertClause.after(column: String): DataFrame = df.add(this public fun InsertClause.after(column: ColumnAccessor<*>): DataFrame = after(column.path()) +@AccessApiOverload public fun InsertClause.after(column: KProperty<*>): DataFrame = after(column.columnName) public fun InsertClause.after(columnPath: ColumnPath): DataFrame { diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/into.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/into.kt index 7026b72e47..307ea4e022 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/into.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/into.kt @@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.AnyFrame import org.jetbrains.kotlinx.dataframe.AnyRow import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.RowExpression +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor import org.jetbrains.kotlinx.dataframe.impl.aggregation.internal import org.jetbrains.kotlinx.dataframe.impl.aggregation.withExpr @@ -15,8 +16,10 @@ import kotlin.reflect.typeOf public fun GroupBy.into(column: String): DataFrame = toDataFrame(column) +@AccessApiOverload public fun GroupBy.into(column: ColumnAccessor): DataFrame = toDataFrame(column.name()) +@AccessApiOverload public fun GroupBy.into(column: KProperty): DataFrame = toDataFrame(column.columnName) public inline fun GroupBy.into( @@ -24,6 +27,7 @@ public inline fun GroupBy.into( noinline expression: RowExpression, ): DataFrame = into(pathOf(columnName ?: groups.name()).cast(), expression) +// @Hide public inline fun GroupBy.into( column: ColumnAccessor, noinline expression: RowExpression, @@ -35,6 +39,7 @@ public inline fun GroupBy.into( } } +@AccessApiOverload public inline fun GroupBy.into( column: KProperty, noinline expression: RowExpression, @@ -58,11 +63,13 @@ public inline fun ReducedGroupBy.into( } } +@AccessApiOverload public inline fun ReducedGroupBy.into( column: ColumnAccessor, noinline expression: RowExpression, ): DataFrame = into(column.name(), expression) +@AccessApiOverload public inline fun ReducedGroupBy.into( column: KProperty, noinline expression: RowExpression, @@ -70,8 +77,10 @@ public inline fun ReducedGroupBy.into( public fun ReducedGroupBy.into(columnName: String): DataFrame = into(columnName) { this } +@AccessApiOverload public fun ReducedGroupBy.into(column: ColumnAccessor): DataFrame = into(column) { this } +@AccessApiOverload public fun ReducedGroupBy.into(column: KProperty): DataFrame = into(column) { this } public fun ReducedGroupBy.concat(): DataFrame = diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/join.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/join.kt index ea54b2c3be..2e2be63679 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/join.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/join.kt @@ -2,6 +2,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.ColumnsContainer import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -95,12 +96,15 @@ public interface JoinDsl : ColumnsSelectionDsl { public infix fun String.match(other: String): ColumnMatch = ColumnMatch(toColumnAccessor(), other.toColumnAccessor()) + @AccessApiOverload public infix fun KProperty.match(other: KProperty): ColumnMatch = ColumnMatch(toColumnAccessor(), other.toColumnAccessor()) + @AccessApiOverload public infix fun ColumnReference.match(other: KProperty): ColumnMatch = ColumnMatch(this, other.toColumnAccessor()) + @AccessApiOverload public infix fun KProperty.match(other: ColumnReference): ColumnMatch = ColumnMatch(toColumnAccessor(), other) } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/map.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/map.kt index 18c339f213..90381b9418 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/map.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/map.kt @@ -7,6 +7,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowExpression import org.jetbrains.kotlinx.dataframe.Selector +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -20,6 +21,7 @@ import kotlin.reflect.typeOf // region ColumnReference +@AccessApiOverload public inline fun ColumnReference.map( infer: Infer = Infer.Nulls, noinline transform: (C) -> R, @@ -71,12 +73,14 @@ public inline fun ColumnsContainer.mapToColumn( noinline body: AddExpression, ): DataColumn = mapToColumn(name, typeOf(), infer, body) +@AccessApiOverload public inline fun ColumnsContainer.mapToColumn( column: ColumnReference, infer: Infer = Infer.Nulls, noinline body: AddExpression, ): DataColumn = mapToColumn(column, typeOf(), infer, body) +@AccessApiOverload public inline fun ColumnsContainer.mapToColumn( column: KProperty, infer: Infer = Infer.Nulls, @@ -90,6 +94,7 @@ public fun ColumnsContainer.mapToColumn( body: AddExpression, ): DataColumn = newColumn(type, name, infer, body) +@AccessApiOverload public fun ColumnsContainer.mapToColumn( column: ColumnReference, type: KType, @@ -97,6 +102,7 @@ public fun ColumnsContainer.mapToColumn( body: AddExpression, ): DataColumn = mapToColumn(column.name(), type, infer, body) +@AccessApiOverload public fun ColumnsContainer.mapToColumn( column: KProperty, type: KType, 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 59b34e8562..38240d79d3 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 @@ -7,6 +7,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowExpression import org.jetbrains.kotlinx.dataframe.aggregation.ColumnsForAggregateSelector +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.columns.values @@ -59,9 +60,11 @@ public fun > DataFrame.maxFor(columns: ColumnsForAggrega public fun DataFrame.maxFor(vararg columns: String): DataRow = maxFor { columns.toComparableColumns() } +@AccessApiOverload public fun > DataFrame.maxFor(vararg columns: ColumnReference): DataRow = maxFor { columns.toColumnSet() } +@AccessApiOverload public fun > DataFrame.maxFor(vararg columns: KProperty): DataRow = maxFor { columns.toColumnSet() } @@ -70,9 +73,11 @@ public fun > DataFrame.max(columns: ColumnsSelector DataFrame.max(vararg columns: String): Comparable = maxOrNull(*columns).suggestIfNull("max") +@AccessApiOverload public fun > DataFrame.max(vararg columns: ColumnReference): C = maxOrNull(*columns).suggestIfNull("max") +@AccessApiOverload public fun > DataFrame.max(vararg columns: KProperty): C = maxOrNull(*columns).suggestIfNull("max") @@ -82,9 +87,11 @@ public fun > DataFrame.maxOrNull(columns: ColumnsSelecto public fun DataFrame.maxOrNull(vararg columns: String): Comparable? = maxOrNull { columns.toComparableColumns() } +@AccessApiOverload public fun > DataFrame.maxOrNull(vararg columns: ColumnReference): C? = maxOrNull { columns.toColumnSet() } +@AccessApiOverload public fun > DataFrame.maxOrNull(vararg columns: KProperty): C? = maxOrNull { columns.toColumnSet() } @@ -99,9 +106,11 @@ public fun > DataFrame.maxBy(expression: RowExpression DataFrame.maxBy(column: String): DataRow = maxByOrNull(column).suggestIfNull("maxBy") +@AccessApiOverload public fun > DataFrame.maxBy(column: ColumnReference): DataRow = maxByOrNull(column).suggestIfNull("maxBy") +@AccessApiOverload public fun > DataFrame.maxBy(column: KProperty): DataRow = maxByOrNull(column).suggestIfNull("maxBy") @@ -111,9 +120,11 @@ public fun > DataFrame.maxByOrNull(expression: RowExpres public fun DataFrame.maxByOrNull(column: String): DataRow? = maxByOrNull(column.toColumnOf?>()) +@AccessApiOverload public fun > DataFrame.maxByOrNull(column: ColumnReference): DataRow? = getOrNull(get(column).asSequence().indexOfMax()) +@AccessApiOverload public fun > DataFrame.maxByOrNull(column: KProperty): DataRow? = maxByOrNull(column.toColumnAccessor()) @@ -128,9 +139,11 @@ public fun > Grouped.maxFor(columns: ColumnsForAggregate public fun Grouped.maxFor(vararg columns: String): DataFrame = maxFor { columns.toComparableColumns() } +@AccessApiOverload public fun > Grouped.maxFor(vararg columns: ColumnReference): DataFrame = maxFor { columns.toColumnSet() } +@AccessApiOverload public fun > Grouped.maxFor(vararg columns: KProperty): DataFrame = maxFor { columns.toColumnSet() } @@ -145,6 +158,7 @@ public fun > Grouped.max( name: String? = null, ): DataFrame = max(name) { columns.toColumnSet() } +@AccessApiOverload public fun > Grouped.max(vararg columns: KProperty, name: String? = null): DataFrame = max(name) { columns.toColumnSet() } @@ -156,12 +170,14 @@ public fun > Grouped.maxOf( public fun > GroupBy.maxBy(rowExpression: RowExpression): ReducedGroupBy = reduce { maxByOrNull(rowExpression) } +@AccessApiOverload public fun > GroupBy.maxBy(column: ColumnReference): ReducedGroupBy = reduce { maxByOrNull(column) } public fun GroupBy.maxBy(column: String): ReducedGroupBy = maxBy(column.toColumnAccessor().cast>()) +@AccessApiOverload public fun > GroupBy.maxBy(column: KProperty): ReducedGroupBy = 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 81309e7d78..0255e8fb93 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 @@ -7,6 +7,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowExpression import org.jetbrains.kotlinx.dataframe.aggregation.ColumnsForAggregateSelector +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.columns.toColumnsSetOf @@ -64,6 +65,7 @@ public fun DataFrame.meanFor( skipNA: Boolean = skipNA_default, ): DataRow = meanFor(skipNA) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.meanFor( vararg columns: KProperty, skipNA: Boolean = skipNA_default, @@ -82,6 +84,7 @@ public fun DataFrame.mean( skipNA: Boolean = skipNA_default, ): Double = mean(skipNA) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.mean(vararg columns: KProperty, skipNA: Boolean = skipNA_default): Double = mean(skipNA) { columns.toColumnSet() } @@ -109,6 +112,7 @@ public fun Grouped.meanFor( skipNA: Boolean = skipNA_default, ): DataFrame = meanFor(skipNA) { columns.toColumnSet() } +@AccessApiOverload public fun Grouped.meanFor( vararg columns: KProperty, skipNA: Boolean = skipNA_default, @@ -132,6 +136,7 @@ public fun Grouped.mean( skipNA: Boolean = skipNA_default, ): DataFrame = mean(name, skipNA) { columns.toColumnSet() } +@AccessApiOverload public fun Grouped.mean( vararg columns: KProperty, name: String? = null, @@ -169,6 +174,7 @@ public fun Pivot.meanFor( separate: Boolean = false, ): DataRow = meanFor(skipNA, separate) { columns.toColumnSet() } +@AccessApiOverload public fun Pivot.meanFor( vararg columns: KProperty, skipNA: Boolean = skipNA_default, @@ -210,6 +216,7 @@ public fun PivotGroupBy.meanFor( skipNA: Boolean = skipNA_default, ): DataFrame = meanFor(skipNA, separate) { columns.toColumnSet() } +@AccessApiOverload public fun PivotGroupBy.meanFor( vararg columns: KProperty, separate: Boolean = false, @@ -229,6 +236,7 @@ public fun PivotGroupBy.mean( skipNA: Boolean = skipNA_default, ): DataFrame = mean(skipNA) { columns.toColumnSet() } +@AccessApiOverload public fun PivotGroupBy.mean( vararg columns: KProperty, 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 fb57e33d77..49e9569db3 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 @@ -7,6 +7,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowExpression import org.jetbrains.kotlinx.dataframe.aggregation.ColumnsForAggregateSelector +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.aggregation.aggregators.Aggregators @@ -63,6 +64,7 @@ public fun DataFrame.medianFor(vararg columns: String): DataRow = medi public fun > DataFrame.medianFor(vararg columns: ColumnReference): DataRow = medianFor { columns.toColumnSet() } +@AccessApiOverload public fun > DataFrame.medianFor(vararg columns: KProperty): DataRow = medianFor { columns.toColumnSet() } @@ -74,6 +76,7 @@ public fun DataFrame.median(vararg columns: String): Any = median { colum public fun > DataFrame.median(vararg columns: ColumnReference): C = median { columns.toColumnSet() } +@AccessApiOverload public fun > DataFrame.median(vararg columns: KProperty): C = median { columns.toColumnSet() } @@ -85,6 +88,7 @@ public fun DataFrame.medianOrNull(vararg columns: String): Any? = medianO public fun > DataFrame.medianOrNull(vararg columns: ColumnReference): C? = medianOrNull { columns.toColumnSet() } +@AccessApiOverload public fun > DataFrame.medianOrNull(vararg columns: KProperty): C? = medianOrNull { columns.toColumnSet() } @@ -106,6 +110,7 @@ public fun Grouped.medianFor(vararg columns: String): DataFrame = medi public fun > Grouped.medianFor(vararg columns: ColumnReference): DataFrame = medianFor { columns.toColumnSet() } +@AccessApiOverload public fun > Grouped.medianFor(vararg columns: KProperty): DataFrame = medianFor { columns.toColumnSet() } @@ -122,6 +127,7 @@ public fun > Grouped.median( name: String? = null, ): DataFrame = median(name) { columns.toColumnSet() } +@AccessApiOverload public fun > Grouped.median(vararg columns: KProperty, name: String? = null): DataFrame = median(name) { columns.toColumnSet() } @@ -149,6 +155,7 @@ public fun > Pivot.medianFor( separate: Boolean = false, ): DataRow = medianFor(separate) { columns.toColumnSet() } +@AccessApiOverload public fun > Pivot.medianFor( vararg columns: KProperty, separate: Boolean = false, @@ -162,6 +169,7 @@ public fun Pivot.median(vararg columns: String): DataRow = median { co public fun > Pivot.median(vararg columns: ColumnReference): DataRow = median { columns.toColumnSet() } +@AccessApiOverload public fun > Pivot.median(vararg columns: KProperty): DataRow = median { columns.toColumnSet() } @@ -189,6 +197,7 @@ public fun > PivotGroupBy.medianFor( separate: Boolean = false, ): DataFrame = medianFor(separate) { columns.toColumnSet() } +@AccessApiOverload public fun > PivotGroupBy.medianFor( vararg columns: KProperty, separate: Boolean = false, @@ -202,6 +211,7 @@ public fun PivotGroupBy.median(vararg columns: String): DataFrame = me public fun > PivotGroupBy.median(vararg columns: ColumnReference): DataFrame = median { columns.toColumnSet() } +@AccessApiOverload public fun > PivotGroupBy.median(vararg columns: KProperty): DataFrame = median { columns.toColumnSet() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/merge.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/merge.kt index 1dd19d24c1..01ce40eb5f 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/merge.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/merge.kt @@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.AnyRow import org.jetbrains.kotlinx.dataframe.ColumnsSelector 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.ColumnAccessor import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -20,9 +21,11 @@ public fun DataFrame.merge(selector: ColumnsSelector): Merge DataFrame.merge(vararg columns: String): Merge> = merge { columns.toColumnSet() } +@AccessApiOverload public inline fun DataFrame.merge(vararg columns: ColumnReference): Merge> = merge { columns.toColumnSet() } +@AccessApiOverload public inline fun DataFrame.merge(vararg columns: KProperty): Merge> = merge { columns.toColumnSet() } @@ -45,6 +48,7 @@ public fun Merge.notNull(): Merge = copy(notNull = t public fun Merge.into(columnName: String): DataFrame = into(pathOf(columnName)) +@AccessApiOverload public fun Merge.into(column: ColumnAccessor<*>): DataFrame = into(column.path()) public fun Merge.intoList(): List = 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 2ec4be8943..3bbdb53a11 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 @@ -7,6 +7,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowExpression import org.jetbrains.kotlinx.dataframe.aggregation.ColumnsForAggregateSelector +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.columns.values @@ -102,6 +103,7 @@ public fun DataFrame.minBy(column: String): DataRow = minByOrNull(colu public fun > DataFrame.minBy(column: ColumnReference): DataRow = minByOrNull(column).suggestIfNull("minBy") +@AccessApiOverload public fun > DataFrame.minBy(column: KProperty): DataRow = minByOrNull(column).suggestIfNull("minBy") @@ -114,6 +116,7 @@ public fun DataFrame.minByOrNull(column: String): DataRow? = public fun > DataFrame.minByOrNull(column: ColumnReference): DataRow? = getOrNull(get(column).asSequence().indexOfMin()) +@AccessApiOverload public fun > DataFrame.minByOrNull(column: KProperty): DataRow? = minByOrNull(column.toColumnAccessor()) @@ -162,6 +165,7 @@ public fun > GroupBy.minBy(column: ColumnReference public fun GroupBy.minBy(column: String): ReducedGroupBy = minBy(column.toColumnAccessor().cast>()) +@AccessApiOverload public fun > GroupBy.minBy(column: KProperty): ReducedGroupBy = minBy(column.toColumnAccessor()) @@ -212,6 +216,7 @@ public fun > Pivot.minBy(column: ColumnReference): R public fun Pivot.minBy(column: String): ReducedPivot = minBy(column.toColumnAccessor().cast>()) +@AccessApiOverload public fun > Pivot.minBy(column: KProperty): ReducedPivot = minBy(column.toColumnAccessor()) @@ -262,6 +267,7 @@ public fun > PivotGroupBy.minBy(column: ColumnReference< public fun PivotGroupBy.minBy(column: String): ReducedPivotGroupBy = minBy(column.toColumnAccessor().cast>()) +@AccessApiOverload public fun > PivotGroupBy.minBy(column: KProperty): ReducedPivotGroupBy = minBy(column.toColumnAccessor()) 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 6fd3f3b597..8e549c6ba7 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 @@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnSelector import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -25,8 +26,10 @@ public fun DataFrame.move(columns: ColumnsSelector): MoveClause< public fun DataFrame.move(vararg cols: String): MoveClause = move { cols.toColumnSet() } +@AccessApiOverload public fun DataFrame.move(vararg cols: ColumnReference): MoveClause = move { cols.toColumnSet() } +@AccessApiOverload public fun DataFrame.move(vararg cols: KProperty): MoveClause = move { cols.toColumnSet() } // endregion @@ -42,6 +45,7 @@ public fun DataFrame.moveTo(newColumnIndex: Int, vararg columns: String): public fun DataFrame.moveTo(newColumnIndex: Int, vararg columns: AnyColumnReference): DataFrame = moveTo(newColumnIndex) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.moveTo(newColumnIndex: Int, vararg columns: KProperty<*>): DataFrame = moveTo(newColumnIndex) { columns.toColumnSet() } @@ -56,6 +60,7 @@ public fun DataFrame.moveToLeft(vararg columns: String): DataFrame = m public fun DataFrame.moveToLeft(vararg columns: AnyColumnReference): DataFrame = moveToLeft { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.moveToLeft(vararg columns: KProperty<*>): DataFrame = moveToLeft { columns.toColumnSet() } @@ -139,6 +144,7 @@ public fun MoveClause.after(column: String): DataFrame = after { public fun MoveClause.after(column: AnyColumnReference): DataFrame = after { column } +@AccessApiOverload public fun MoveClause.after(column: KProperty<*>): DataFrame = after { column.toColumnAccessor() } // endregion diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt index c42ce19168..d3a51a041f 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt @@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.AnyFrame 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.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.toColumnSet import org.jetbrains.kotlinx.dataframe.impl.api.Parsers @@ -25,9 +26,11 @@ public fun DataFrame.parse(options: ParserOptions? = null, columns: Colum public fun DataFrame.parse(vararg columns: String, options: ParserOptions? = null): DataFrame = parse(options) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.parse(vararg columns: ColumnReference, options: ParserOptions? = null): DataFrame = parse(options) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.parse(vararg columns: KProperty, options: ParserOptions? = null): DataFrame = parse(options) { columns.toColumnSet() } 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 16b67b84b4..9c7fcf9ac2 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 @@ -8,6 +8,7 @@ import org.jetbrains.kotlinx.dataframe.Selector import org.jetbrains.kotlinx.dataframe.aggregation.Aggregatable import org.jetbrains.kotlinx.dataframe.aggregation.AggregateBody import org.jetbrains.kotlinx.dataframe.aggregation.AggregateGroupedDsl +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.toColumnSet @@ -30,13 +31,16 @@ public interface PivotDsl : ColumnsSelectionDsl { public infix fun KProperty.then(other: ColumnsResolver): ColumnSet = toColumnAccessor() then other + @AccessApiOverload public infix fun ColumnsResolver.then(other: KProperty): ColumnSet = this then other.toColumnAccessor() + @AccessApiOverload public infix fun KProperty.then(other: KProperty): ColumnSet = toColumnAccessor() then other.toColumnAccessor() public infix fun KProperty.then(other: String): ColumnSet = toColumnAccessor() then other.toColumnOf() + @AccessApiOverload public infix fun String.then(other: KProperty): ColumnSet = toColumnOf() then other.toColumnAccessor() } @@ -50,9 +54,11 @@ public fun DataFrame.pivot(inward: Boolean? = null, columns: PivotColumns public fun DataFrame.pivot(vararg columns: String, inward: Boolean? = null): Pivot = pivot(inward) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.pivot(vararg columns: AnyColumnReference, inward: Boolean? = null): Pivot = pivot(inward) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.pivot(vararg columns: KProperty<*>, inward: Boolean? = null): Pivot = pivot(inward) { columns.toColumnSet() } @@ -66,9 +72,11 @@ public fun DataFrame.pivotMatches(inward: Boolean = true, columns: Column public fun DataFrame.pivotMatches(vararg columns: String, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.pivotMatches(vararg columns: AnyColumnReference, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.pivotMatches(vararg columns: KProperty<*>, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumnSet() } @@ -82,9 +90,11 @@ public fun DataFrame.pivotCounts(inward: Boolean = true, columns: Columns public fun DataFrame.pivotCounts(vararg columns: String, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.pivotCounts(vararg columns: AnyColumnReference, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.pivotCounts(vararg columns: KProperty<*>, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumnSet() } @@ -99,12 +109,14 @@ public fun DataFrame.pivotCounts(vararg columns: KProperty<*>, inward: Bo public fun GroupBy<*, G>.pivot(inward: Boolean = true, columns: ColumnsSelector): PivotGroupBy = PivotGroupByImpl(this, columns, inward) +@AccessApiOverload public fun GroupBy<*, G>.pivot(vararg columns: AnyColumnReference, inward: Boolean = true): PivotGroupBy = pivot(inward) { columns.toColumnSet() } public fun GroupBy<*, G>.pivot(vararg columns: String, inward: Boolean = true): PivotGroupBy = pivot(inward) { columns.toColumnSet() } +@AccessApiOverload public fun GroupBy<*, G>.pivot(vararg columns: KProperty<*>, inward: Boolean = true): PivotGroupBy = pivot(inward) { columns.toColumnSet() } @@ -118,9 +130,11 @@ public fun GroupBy<*, G>.pivotMatches(inward: Boolean = true, columns: Colum public fun GroupBy<*, G>.pivotMatches(vararg columns: String, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumnSet() } +@AccessApiOverload public fun GroupBy<*, G>.pivotMatches(vararg columns: AnyColumnReference, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumnSet() } +@AccessApiOverload public fun GroupBy<*, G>.pivotMatches(vararg columns: KProperty<*>, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumnSet() } @@ -134,9 +148,11 @@ public fun GroupBy<*, G>.pivotCounts(inward: Boolean = true, columns: Column public fun GroupBy<*, G>.pivotCounts(vararg columns: String, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumnSet() } +@AccessApiOverload public fun GroupBy<*, G>.pivotCounts(vararg columns: AnyColumnReference, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumnSet() } +@AccessApiOverload public fun GroupBy<*, G>.pivotCounts(vararg columns: KProperty<*>, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumnSet() } @@ -156,11 +172,13 @@ public fun AggregateGroupedDsl.pivot( public fun AggregateGroupedDsl.pivot(vararg columns: String, inward: Boolean = true): PivotGroupBy = pivot(inward) { columns.toColumnSet() } +@AccessApiOverload public fun AggregateGroupedDsl.pivot( vararg columns: AnyColumnReference, inward: Boolean = true, ): PivotGroupBy = pivot(inward) { columns.toColumnSet() } +@AccessApiOverload public fun AggregateGroupedDsl.pivot(vararg columns: KProperty<*>, inward: Boolean = true): PivotGroupBy = pivot(inward) { columns.toColumnSet() } @@ -176,11 +194,13 @@ public fun AggregateGroupedDsl.pivotMatches( public fun AggregateGroupedDsl.pivotMatches(vararg columns: String, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumnSet() } +@AccessApiOverload public fun AggregateGroupedDsl.pivotMatches( vararg columns: AnyColumnReference, inward: Boolean = true, ): DataFrame = pivotMatches(inward) { columns.toColumnSet() } +@AccessApiOverload public fun AggregateGroupedDsl.pivotMatches(vararg columns: KProperty<*>, inward: Boolean = true): DataFrame = pivotMatches(inward) { columns.toColumnSet() } @@ -196,11 +216,13 @@ public fun AggregateGroupedDsl.pivotCounts( public fun AggregateGroupedDsl.pivotCounts(vararg columns: String, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumnSet() } +@AccessApiOverload public fun AggregateGroupedDsl.pivotCounts( vararg columns: AnyColumnReference, inward: Boolean = true, ): DataFrame = pivotCounts(inward) { columns.toColumnSet() } +@AccessApiOverload public fun AggregateGroupedDsl.pivotCounts(vararg columns: KProperty<*>, inward: Boolean = true): DataFrame = pivotCounts(inward) { columns.toColumnSet() } 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 39ef71fa41..0e39146af7 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 @@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.toColumnSet @@ -20,8 +21,10 @@ public fun DataFrame.remove(columns: ColumnsSelector): DataFrame public fun DataFrame.remove(vararg columns: String): DataFrame = remove { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.remove(vararg columns: AnyColumnReference): DataFrame = remove { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.remove(vararg columns: KProperty<*>): DataFrame = remove { columns.toColumnSet() } // endregion @@ -32,8 +35,10 @@ public infix operator fun DataFrame.minus(columns: ColumnsSelector) public infix operator fun DataFrame.minus(column: String): DataFrame = remove(column) +@AccessApiOverload public infix operator fun DataFrame.minus(column: AnyColumnReference): DataFrame = remove(column) +@AccessApiOverload public infix operator fun DataFrame.minus(columns: KProperty<*>): DataFrame = remove(columns) // endregion 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 92dc407ada..a82501e27b 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 @@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.dataframe.api 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.annotations.HasSchema import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine @@ -37,9 +38,11 @@ public fun DataFrame.rename(vararg mappings: Pair): DataF @Interpretable("Rename") public fun DataFrame.rename(columns: ColumnsSelector): RenameClause = RenameClause(this, columns) +@AccessApiOverload public fun DataFrame.rename(vararg cols: ColumnReference): RenameClause = rename { cols.toColumnSet() } +@AccessApiOverload public fun DataFrame.rename(vararg cols: KProperty): RenameClause = rename { cols.toColumnSet() } public fun DataFrame.rename(vararg cols: String): RenameClause = rename { cols.toColumnSet() } @@ -66,6 +69,7 @@ public fun DataFrame.renameToCamelCase(): DataFrame = colsAtAnyDepth().colsOf() }.with { it.renameToCamelCase() } +@AccessApiOverload public fun RenameClause.into(vararg newColumns: ColumnReference<*>): DataFrame = into(*newColumns.map { it.name() }.toTypedArray()) @@ -73,6 +77,7 @@ public fun RenameClause.into(vararg newColumns: ColumnReference<*>) @Interpretable("RenameInto") public fun RenameClause.into(vararg newNames: String): DataFrame = renameImpl(newNames) +@AccessApiOverload public fun RenameClause.into(vararg newNames: KProperty<*>): DataFrame = into(*newNames.map { it.name }.toTypedArray()) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/replace.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/replace.kt index 251c359c47..22ff9785a9 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/replace.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/replace.kt @@ -6,6 +6,7 @@ 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.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.toColumnSet import org.jetbrains.kotlinx.dataframe.get @@ -19,9 +20,11 @@ public fun DataFrame.replace(columns: ColumnsSelector): ReplaceC public fun DataFrame.replace(vararg columns: String): ReplaceClause = replace { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.replace(vararg columns: ColumnReference): ReplaceClause = replace { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.replace(vararg columns: KProperty): ReplaceClause = replace { 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 90526779cd..31366af1f9 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 @@ -5,6 +5,7 @@ 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.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.api.Select.SelectSelectingOptions @@ -71,6 +72,7 @@ public fun DataFrame.select(columns: ColumnsSelector): DataFrame * @include [SelectingColumns.KProperties.WithExample] {@include [SetSelectOperationArg]} * @param [columns] The [KProperties][KProperty] used to select the columns of this [DataFrame]. */ +@AccessApiOverload public fun DataFrame.select(vararg columns: KProperty<*>): DataFrame = select { columns.toColumnSet() } /** @@ -85,6 +87,7 @@ public fun DataFrame.select(vararg columns: String): DataFrame = selec * @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetSelectOperationArg]} * @param [columns] The [Column Accessors][ColumnReference] used to select the columns of this [DataFrame]. */ +@AccessApiOverload public fun DataFrame.select(vararg columns: AnyColumnReference): DataFrame = select { columns.toColumnSet() } // endregion 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 a64f5f8439..ad3e4e60a0 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 @@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataFrameExpression import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.Selector +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.ColumnSet @@ -106,10 +107,12 @@ public fun > C.sortWith(comparator: (T, T) -> Int): C = sor public fun DataFrame.sortBy(columns: SortColumnsSelector): DataFrame = sortByImpl(UnresolvedColumnsPolicy.Fail, columns) +@AccessApiOverload public fun DataFrame.sortBy(vararg cols: ColumnReference<*>): DataFrame = sortBy { cols.toColumnSet() } public fun DataFrame.sortBy(vararg cols: String): DataFrame = sortBy { cols.toColumnSet() } +@AccessApiOverload public fun DataFrame.sortBy(vararg cols: KProperty?>): DataFrame = sortBy { cols.toColumnSet() } public fun DataFrame.sortWith(comparator: Comparator>): DataFrame { @@ -125,11 +128,13 @@ public fun DataFrame.sortByDesc(columns: SortColumnsSelector): D return sortByImpl { set.desc() } } +@AccessApiOverload public fun DataFrame.sortByDesc(vararg columns: KProperty?>): DataFrame = sortByDesc { columns.toColumnSet() } public fun DataFrame.sortByDesc(vararg columns: String): DataFrame = sortByDesc { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.sortByDesc(vararg columns: ColumnReference<*>): DataFrame = sortByDesc { columns.toColumnSet() } @@ -139,8 +144,10 @@ public fun DataFrame.sortByDesc(vararg columns: ColumnReference<*>): Data public fun GroupBy.sortBy(vararg cols: String): GroupBy = sortBy { cols.toColumnSet() } +@AccessApiOverload public fun GroupBy.sortBy(vararg cols: ColumnReference<*>): GroupBy = sortBy { cols.toColumnSet() } +@AccessApiOverload public fun GroupBy.sortBy(vararg cols: KProperty?>): GroupBy = sortBy { cols.toColumnSet() } @@ -148,9 +155,11 @@ public fun GroupBy.sortBy(selector: SortColumnsSelector): public fun GroupBy.sortByDesc(vararg cols: String): GroupBy = sortByDesc { cols.toColumnSet() } +@AccessApiOverload public fun GroupBy.sortByDesc(vararg cols: ColumnReference<*>): GroupBy = sortByDesc { cols.toColumnSet() } +@AccessApiOverload public fun GroupBy.sortByDesc(vararg cols: KProperty?>): GroupBy = sortByDesc { cols.toColumnSet() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/split.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/split.kt index 56fa8d23ab..5f9161f47f 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/split.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/split.kt @@ -6,6 +6,7 @@ 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.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.ColumnSet @@ -25,8 +26,10 @@ public fun DataFrame.split(columns: ColumnsSelector): Split DataFrame.split(vararg columns: String): Split = split { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.split(vararg columns: ColumnReference): Split = split { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.split(vararg columns: KProperty): Split = split { columns.toColumnSet() } public class Split(internal val df: DataFrame, internal val columns: ColumnsSelector) { diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/std.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/std.kt index af6a07ca71..334bc398e0 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/std.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/std.kt @@ -7,6 +7,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowExpression import org.jetbrains.kotlinx.dataframe.aggregation.ColumnsForAggregateSelector +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.columns.toColumnsSetOf @@ -72,6 +73,7 @@ public fun DataFrame.stdFor( ddof: Int = ddof_default, ): DataRow = stdFor(skipNA, ddof) { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.stdFor( vararg columns: KProperty, skipNA: Boolean = skipNA_default, @@ -88,6 +90,7 @@ public fun DataFrame.std(vararg columns: ColumnReference): Doubl public fun DataFrame.std(vararg columns: String): Double = std { columns.toColumnsSetOf() } +@AccessApiOverload public fun DataFrame.std(vararg columns: KProperty): Double = std { columns.toColumnSet() } public inline fun DataFrame.stdOf( @@ -121,6 +124,7 @@ public fun Grouped.stdFor( ddof: Int = ddof_default, ): DataFrame = stdFor(skipNA, ddof) { columns.toColumnSet() } +@AccessApiOverload public fun Grouped.stdFor( vararg columns: KProperty, skipNA: Boolean = skipNA_default, @@ -148,6 +152,7 @@ public fun Grouped.std( ddof: Int = ddof_default, ): DataFrame = std(name, skipNA, ddof) { columns.toColumnsSetOf() } +@AccessApiOverload public fun Grouped.std( vararg columns: KProperty, name: String? = null, @@ -193,6 +198,7 @@ public fun Pivot.stdFor( ddof: Int = ddof_default, ): DataRow = stdFor(separate, skipNA, ddof) { columns.toColumnSet() } +@AccessApiOverload public fun Pivot.stdFor( vararg columns: KProperty, separate: Boolean = false, @@ -218,6 +224,7 @@ public fun Pivot.std( ddof: Int = ddof_default, ): DataRow = std(skipNA, ddof) { columns.toColumnsSetOf() } +@AccessApiOverload public fun Pivot.std( vararg columns: KProperty, skipNA: Boolean = skipNA_default, @@ -261,6 +268,7 @@ public fun PivotGroupBy.stdFor( ddof: Int = ddof_default, ): DataFrame = stdFor(separate, skipNA, ddof) { columns.toColumnSet() } +@AccessApiOverload public fun PivotGroupBy.stdFor( vararg columns: KProperty, separate: Boolean = false, @@ -286,6 +294,7 @@ public fun PivotGroupBy.std( ddof: Int = ddof_default, ): DataFrame = std(skipNA, ddof) { columns.toColumnsSetOf() } +@AccessApiOverload public fun PivotGroupBy.std( vararg columns: KProperty, skipNA: Boolean = skipNA_default, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/sum.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/sum.kt index be579ca161..548fc47048 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/sum.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/sum.kt @@ -7,6 +7,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowExpression import org.jetbrains.kotlinx.dataframe.aggregation.ColumnsForAggregateSelector +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.columns.toColumnsSetOf @@ -56,20 +57,24 @@ public fun DataFrame.sumFor(columns: ColumnsForAggregateSelec public fun DataFrame.sumFor(vararg columns: String): DataRow = sumFor { columns.toColumnsSetOf() } +@AccessApiOverload public fun DataFrame.sumFor(vararg columns: ColumnReference): DataRow = sumFor { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.sumFor(vararg columns: KProperty): DataRow = sumFor { columns.toColumnSet() } public inline fun DataFrame.sum(noinline columns: ColumnsSelector): C = (Aggregators.sum.aggregateAll(this, columns) as C?) ?: C::class.zero() +@AccessApiOverload public inline fun DataFrame.sum(vararg columns: ColumnReference): C = sum { columns.toColumnSet() } public fun DataFrame.sum(vararg columns: String): Number = sum { columns.toColumnsSetOf() } +@AccessApiOverload public inline fun DataFrame.sum(vararg columns: KProperty): C = sum { columns.toColumnSet() } @@ -87,9 +92,11 @@ public fun Grouped.sumFor(columns: ColumnsForAggregateSelecto public fun Grouped.sumFor(vararg columns: String): DataFrame = sumFor { columns.toNumberColumns() } +@AccessApiOverload public fun Grouped.sumFor(vararg columns: ColumnReference): DataFrame = sumFor { columns.toColumnSet() } +@AccessApiOverload public fun Grouped.sumFor(vararg columns: KProperty): DataFrame = sumFor { columns.toColumnSet() } @@ -99,9 +106,11 @@ public fun Grouped.sum(name: String? = null, columns: Columns public fun Grouped.sum(vararg columns: String, name: String? = null): DataFrame = sum(name) { columns.toNumberColumns() } +@AccessApiOverload public fun Grouped.sum(vararg columns: ColumnReference, name: String? = null): DataFrame = sum(name) { columns.toColumnSet() } +@AccessApiOverload public fun Grouped.sum(vararg columns: KProperty, name: String? = null): DataFrame = sum(name) { columns.toColumnSet() } @@ -124,11 +133,13 @@ public fun Pivot.sumFor( public fun Pivot.sumFor(vararg columns: String, separate: Boolean = false): DataRow = sumFor(separate) { columns.toNumberColumns() } +@AccessApiOverload public fun Pivot.sumFor( vararg columns: ColumnReference, separate: Boolean = false, ): DataRow = sumFor(separate) { columns.toColumnSet() } +@AccessApiOverload public fun Pivot.sumFor(vararg columns: KProperty, separate: Boolean = false): DataRow = sumFor(separate) { columns.toColumnSet() } @@ -136,8 +147,10 @@ public fun Pivot.sum(columns: ColumnsSelector): DataRo public fun Pivot.sum(vararg columns: String): DataRow = sum { columns.toNumberColumns() } +@AccessApiOverload public fun Pivot.sum(vararg columns: ColumnReference): DataRow = sum { columns.toColumnSet() } +@AccessApiOverload public fun Pivot.sum(vararg columns: KProperty): DataRow = sum { columns.toColumnSet() } public inline fun Pivot.sumOf(crossinline expression: RowExpression): DataRow = @@ -157,11 +170,13 @@ public fun PivotGroupBy.sumFor( public fun PivotGroupBy.sumFor(vararg columns: String, separate: Boolean = false): DataFrame = sumFor(separate) { columns.toNumberColumns() } +@AccessApiOverload public fun PivotGroupBy.sumFor( vararg columns: ColumnReference, separate: Boolean = false, ): DataFrame = sumFor(separate) { columns.toColumnSet() } +@AccessApiOverload public fun PivotGroupBy.sumFor( vararg columns: KProperty, separate: Boolean = false, @@ -172,9 +187,11 @@ public fun PivotGroupBy.sum(columns: ColumnsSelector): public fun PivotGroupBy.sum(vararg columns: String): DataFrame = sum { columns.toNumberColumns() } +@AccessApiOverload public fun PivotGroupBy.sum(vararg columns: ColumnReference): DataFrame = sum { columns.toColumnSet() } +@AccessApiOverload public fun PivotGroupBy.sum(vararg columns: KProperty): DataFrame = sum { columns.toColumnSet() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/typeConversions.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/typeConversions.kt index 9cd34f7ea9..2f2ccc6e7e 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/typeConversions.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/typeConversions.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlinx.dataframe.ColumnSelector 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.columns.ColumnAccessor import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath @@ -222,6 +223,7 @@ public inline fun Iterable.toValueColumn(name: String = ""): Valu public inline fun Iterable.toValueColumn(column: ColumnAccessor): ValueColumn = toValueColumn(column.name()) +@AccessApiOverload public inline fun Iterable.toValueColumn(column: KProperty): ValueColumn = toValueColumn(column.columnName) @@ -325,6 +327,7 @@ public inline fun Iterable<*>.toColumnOf(name: String = ""): DataCol public inline fun Iterable.toColumn(ref: ColumnReference): DataColumn = DataColumn.createByType(ref.name(), asList()).forceResolve() +@AccessApiOverload public inline fun Iterable.toColumn(property: KProperty): DataColumn = DataColumn.createByType(property.columnName, asList()).forceResolve() @@ -356,6 +359,7 @@ public fun DataFrame.asColumnGroup(column: ColumnGroupAccessor): Colum public fun DataFrame.asGroupBy(groupedColumnName: String): GroupBy = GroupByImpl(this, getFrameColumn(groupedColumnName).castFrameColumn()) { none() } +@AccessApiOverload public fun DataFrame.asGroupBy(groupedColumn: ColumnReference>): GroupBy = GroupByImpl(this, getFrameColumn(groupedColumn.name()).castFrameColumn()) { none() } 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 837154cce7..6a3772175f 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 @@ -5,6 +5,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.ColumnKind import org.jetbrains.kotlinx.dataframe.columns.toColumnSet import org.jetbrains.kotlinx.dataframe.impl.api.createDataFrameImpl @@ -29,6 +30,8 @@ public fun DataFrame.unfold(columns: ColumnsSelector): DataFrame public fun DataFrame.unfold(vararg columns: String): DataFrame = unfold { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.unfold(vararg columns: AnyColumnReference): DataFrame = unfold { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.unfold(vararg columns: KProperty<*>): DataFrame = unfold { columns.toColumnSet() } 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 8f0311c53d..6ef82d3e33 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 @@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.toColumnSet @@ -20,9 +21,11 @@ public fun DataFrame.ungroup(columns: ColumnsSelector): DataFram public fun DataFrame.ungroup(vararg columns: String): DataFrame = ungroup { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.ungroup(vararg columns: AnyColumnReference): DataFrame = ungroup { columns.toColumnSet() } +@AccessApiOverload public fun DataFrame.ungroup(vararg columns: KProperty<*>): DataFrame = ungroup { columns.toColumnSet() } // endregion diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/update.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/update.kt index b59f32bad6..114a386ae9 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/update.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/update.kt @@ -8,6 +8,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrameExpression import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowColumnExpression import org.jetbrains.kotlinx.dataframe.RowValueFilter +import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.api.Update.Grammar @@ -52,6 +53,8 @@ public class Update( override fun toString(): String = "Update(df=$df, filter=$filter, columns=$columns)" + // region KDoc declarations + /* * This argument providing the (clickable) name of the update-like function. * Note: If clickable, make sure to [alias][your type]. @@ -125,6 +128,8 @@ public class Update( /** @param [columns\] The [Strings][String] corresponding to the names of columns belonging to this [DataFrame] to update. */ internal interface ColumnNamesParam + + // endregion } // region update @@ -172,6 +177,7 @@ public fun DataFrame.update(vararg columns: String): Update = up * @include [UpdateWithNote] * @include [Update.KPropertiesParam] */ +@AccessApiOverload public fun DataFrame.update(vararg columns: KProperty): Update = update { columns.toColumnSet() } /** @@ -180,6 +186,7 @@ public fun DataFrame.update(vararg columns: KProperty): Update DataFrame.update(vararg columns: ColumnReference): Update = update { columns.toColumnSet() } @@ -418,6 +425,7 @@ public fun Update.notNull(expression: UpdateExpression): * @include [Update.ColumnAccessorsParam] * @param [expression] The {@include [ExpressionsGivenRow.RowValueExpressionLink]} to update the rows with. */ +@AccessApiOverload public fun DataFrame.update( firstCol: ColumnReference, vararg cols: ColumnReference, @@ -436,6 +444,7 @@ public fun DataFrame.update( * @include [Update.KPropertiesParam] * @param [expression] The {@include [ExpressionsGivenRow.RowValueExpressionLink]} to update the rows with. */ +@AccessApiOverload public fun DataFrame.update( firstCol: KProperty, vararg cols: KProperty,