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..f87cd4dbe4 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 @@ -5,7 +5,13 @@ import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine +import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.toColumnSet +import org.jetbrains.kotlinx.dataframe.documentation.DocumentationUrls +import org.jetbrains.kotlinx.dataframe.documentation.DocumentationUrls.Select +import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources +import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns +import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.OperationArg import org.jetbrains.kotlinx.dataframe.impl.api.removeImpl import kotlin.reflect.KProperty @@ -13,27 +19,115 @@ import kotlin.reflect.KProperty // region remove +/** + * ## The Remove Operation + * + * Removes the specified [columns] from the original [DataFrame] and returns a new [DataFrame] without them. + * + * @include [SelectingColumns.ColumnGroupsAndNestedColumnsMention] + * + * See [Selecting Columns][Select.SelectSelectingOptions]. + * + * For more information: {@include [DocumentationUrls.Remove]} + */ +internal interface Remove + +/** {@set [SelectingColumns.OperationArg] [remove][remove]} */ +@ExcludeFromSources +private interface SetRemoveOperationArg + +/** + * {@include [Remove]} + * ### This Remove Overload + */ +@ExcludeFromSources +private interface CommonRemoveDocs + +/** + * @include [CommonRemoveDocs] + * @include [SelectingColumns.Dsl.WithExample] {@include [SetRemoveOperationArg]} + * @param [columns] The [Columns Selector][ColumnsSelector] used to remove the columns of this [DataFrame]. + */ @Refine @Interpretable("Remove0") public fun DataFrame.remove(columns: ColumnsSelector): DataFrame = removeImpl(allowMissingColumns = true, columns = columns).df +/** + * @include [CommonRemoveDocs] + * @include [SelectingColumns.ColumnNames.WithExample] {@include [SetRemoveOperationArg]} + * @param [columns] The [Column Names][String] used to remove the columns of this [DataFrame]. + */ public fun DataFrame.remove(vararg columns: String): DataFrame = remove { columns.toColumnSet() } +/** + * @include [CommonRemoveDocs] + * @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetRemoveOperationArg]} + * @param [columns] The [Column Accessors][ColumnReference] used to remove the columns of this [DataFrame]. + */ public fun DataFrame.remove(vararg columns: AnyColumnReference): DataFrame = remove { columns.toColumnSet() } +/** + * @include [CommonRemoveDocs] + * @include [SelectingColumns.KProperties.WithExample] {@include [SetRemoveOperationArg]} + * @param [columns] The [KProperties][KProperty] used to remove the columns of this [DataFrame]. + */ public fun DataFrame.remove(vararg columns: KProperty<*>): DataFrame = remove { columns.toColumnSet() } // endregion // region minus +/** + * ## The Minus Operation + * + * Removes the specified [columns] from the original [DataFrame] and returns a new [DataFrame] without them. + * + * @include [SelectingColumns.ColumnGroupsAndNestedColumnsMention] + * + * See [Selecting Columns][Select.SelectSelectingOptions]. + * + * Works exactly as [remove]. For more information: {@include [DocumentationUrls.Remove]} + */ +internal interface Minus + +/** {@set [SelectingColumns.OperationArg] [minus][minus]} */ +@ExcludeFromSources +private interface SetMinusOperationArg + +/** + * {@include [Minus]} + * ### This Minus Overload + */ +@ExcludeFromSources +private interface CommonMinusDocs + +/** + * @include [CommonMinusDocs] + * @include [SelectingColumns.Dsl.WithExample] {@include [SetMinusOperationArg]} + * @param [columns] The [Columns Selector][ColumnsSelector] used to remove the columns of this [DataFrame]. + */ public infix operator fun DataFrame.minus(columns: ColumnsSelector): DataFrame = remove(columns) +/** + * @include [CommonMinusDocs] + * @include [SelectingColumns.ColumnNames.WithExample] {@include [SetMinusOperationArg]} + * @param [columns] The [Column Names][String] used to remove the columns of this [DataFrame]. + */ public infix operator fun DataFrame.minus(column: String): DataFrame = remove(column) +/** + * @include [CommonMinusDocs] + * @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetMinusOperationArg]} + * @param [columns] The [Column Accessors][ColumnReference] used to remove the columns of this [DataFrame]. + */ public infix operator fun DataFrame.minus(column: AnyColumnReference): DataFrame = remove(column) +/** + * @include [CommonMinusDocs] + * @include [SelectingColumns.KProperties.WithExample] {@include [SetMinusOperationArg]} + * @param [columns] The [KProperties][KProperty] used to remove the columns of this [DataFrame]. + */ public infix operator fun DataFrame.minus(columns: KProperty<*>): DataFrame = remove(columns) // endregion diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/select.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/select.kt index 90526779cd..d4e67d1b43 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 @@ -33,6 +33,8 @@ import kotlin.reflect.KProperty * * Returns a new [DataFrame] with only the columns selected by [columns]. * + * @include [SelectingColumns.ColumnGroupsAndNestedColumnsMention] + * * See [Selecting Columns][SelectSelectingOptions]. * * For more information: {@include [DocumentationUrls.Select]} diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/DocumentationUrls.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/DocumentationUrls.kt index 0bbf4f5b1e..4fd9836b22 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/DocumentationUrls.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/DocumentationUrls.kt @@ -74,4 +74,7 @@ internal interface DocumentationUrls { /** [See `update` on the documentation website.]({@include [Url]}/update.html) */ interface Update + + /** [See `remove` on the documentation website.]({@include [Url]}/remove.html) */ + interface Remove } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/SelectingColumns.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/SelectingColumns.kt index 92abcb9e69..a14cc793ee 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/SelectingColumns.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/SelectingColumns.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlinx.dataframe.api.gather import org.jetbrains.kotlinx.dataframe.api.select import org.jetbrains.kotlinx.dataframe.api.update import org.jetbrains.kotlinx.dataframe.columns.ColumnReference +import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.SingleColumn @@ -47,6 +48,11 @@ internal interface SelectingColumnsLink */ internal interface SelectingColumns { + /** + * This operation can also be used on [ColumnGroup] and nested columns. + */ + interface ColumnGroupsAndNestedColumnsMention + /* * The key for a @set that will define the operation name for the examples below. * Make sure to [alias][your examples].