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 9d4ffa05cf..2e8e2b5592 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 @@ -38,6 +38,8 @@ import kotlin.reflect.KProperty * ### Check out: [Grammar][FillNulls.Grammar] * * For more information: {@include [DocumentationUrls.Fill.FillNulls]} + * + * See also [dropNulls], which removes rows with `null` values instead of replacing these values. */ internal interface FillNulls { @@ -168,6 +170,8 @@ internal inline val Float?.isNA: Boolean get() = this == null || this.isNaN() * ### Check out: [Grammar][FillNaNs.Grammar] * * For more information: {@include [DocumentationUrls.Fill.FillNaNs]} + * + * See also [dropNaNs], which removes rows with [`NaN`][NaN] values instead of replacing these values. */ internal interface FillNaNs { @@ -243,6 +247,8 @@ public fun DataFrame.fillNaNs(vararg columns: ColumnReference): Upd * ### Check out: [Grammar][FillNA.Grammar] * * For more information: {@include [DocumentationUrls.Fill.FillNA]} + * + * See also [dropNA], which removes rows with [`NA`][NA] values instead of replacing these values. */ internal interface FillNA { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Access.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Access.kt index 8e3b16a7ff..e784faca6b 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Access.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Access.kt @@ -2,10 +2,7 @@ package org.jetbrains.kotlinx.dataframe.samples.api -import org.jetbrains.kotlinx.dataframe.api.add -import org.jetbrains.kotlinx.dataframe.api.after import org.jetbrains.kotlinx.dataframe.api.chunked -import org.jetbrains.kotlinx.dataframe.api.colsOf import org.jetbrains.kotlinx.dataframe.api.distinct import org.jetbrains.kotlinx.dataframe.api.distinctBy import org.jetbrains.kotlinx.dataframe.api.drop @@ -14,25 +11,17 @@ import org.jetbrains.kotlinx.dataframe.api.dropNA import org.jetbrains.kotlinx.dataframe.api.dropNaNs import org.jetbrains.kotlinx.dataframe.api.dropNulls import org.jetbrains.kotlinx.dataframe.api.dropWhile -import org.jetbrains.kotlinx.dataframe.api.fillNaNs import org.jetbrains.kotlinx.dataframe.api.first import org.jetbrains.kotlinx.dataframe.api.forEach -import org.jetbrains.kotlinx.dataframe.api.gather import org.jetbrains.kotlinx.dataframe.api.getColumn import org.jetbrains.kotlinx.dataframe.api.getColumnGroup import org.jetbrains.kotlinx.dataframe.api.getColumns -import org.jetbrains.kotlinx.dataframe.api.group import org.jetbrains.kotlinx.dataframe.api.groupBy -import org.jetbrains.kotlinx.dataframe.api.into -import org.jetbrains.kotlinx.dataframe.api.isColumnGroup -import org.jetbrains.kotlinx.dataframe.api.map import org.jetbrains.kotlinx.dataframe.api.mapToRows import org.jetbrains.kotlinx.dataframe.api.maxBy import org.jetbrains.kotlinx.dataframe.api.maxByOrNull import org.jetbrains.kotlinx.dataframe.api.minBy import org.jetbrains.kotlinx.dataframe.api.minus -import org.jetbrains.kotlinx.dataframe.api.move -import org.jetbrains.kotlinx.dataframe.api.notNull import org.jetbrains.kotlinx.dataframe.api.remove import org.jetbrains.kotlinx.dataframe.api.rows import org.jetbrains.kotlinx.dataframe.api.select @@ -40,9 +29,7 @@ import org.jetbrains.kotlinx.dataframe.api.single import org.jetbrains.kotlinx.dataframe.api.take import org.jetbrains.kotlinx.dataframe.api.takeLast import org.jetbrains.kotlinx.dataframe.api.takeWhile -import org.jetbrains.kotlinx.dataframe.api.update import org.jetbrains.kotlinx.dataframe.api.values -import org.jetbrains.kotlinx.dataframe.api.withZero import org.jetbrains.kotlinx.dataframe.api.xs import org.jetbrains.kotlinx.dataframe.explainer.TransformDataFrameExpressions import org.jetbrains.kotlinx.dataframe.get @@ -443,181 +430,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun columnSelectorsUsages() { - // SampleStart - df.select { age and name } - df.fillNaNs { colsAtAnyDepth().colsOf() }.withZero() - df.remove { cols { it.hasNulls() } } - df.group { cols { it.data != name } }.into { "nameless" } - df.update { city }.notNull { it.lowercase() } - df.gather { colsOf() }.into("key", "value") - df.move { name.firstName and name.lastName }.after { city } - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun columnSelectors_properties() { - // SampleStart - // by column name - df.select { it.name } - df.select { name } - - // by column path - df.select { name.firstName } - - // with a new name - df.select { name named "Full Name" } - - // converted - df.select { name.firstName.map { it.lowercase() } } - - // column arithmetics - df.select { 2021 - age } - - // two columns - df.select { name and age } - - // range of columns - df.select { name..age } - - // all columns of ColumnGroup - df.select { name.allCols() } - - // traversal of columns at any depth from here excluding ColumnGroups - df.select { name.colsAtAnyDepth().filter { !it.isColumnGroup() } } - - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun columnSelectors_strings() { - // SampleStart - // by column name - df.select { it["name"] } - - // by column path - df.select { it["name"]["firstName"] } - df.select { "name"["firstName"] } - - // with a new name - df.select { "name" named "Full Name" } - - // converted - df.select { "name"["firstName"]().map { it.uppercase() } } - - // column arithmetics - df.select { 2021 - "age"() } - - // two columns - df.select { "name" and "age" } - - // by range of names - df.select { "name".."age" } - - // all columns of ColumnGroup - df.select { "name".allCols() } - - // traversal of columns at any depth from here excluding ColumnGroups - df.select { "name".colsAtAnyDepth().filter { !it.isColumnGroup() } } - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun columnsSelectorByIndices() { - // SampleStart - // by index - df.select { col(2) } - - // by several indices - df.select { cols(0, 1, 3) } - - // by range of indices - df.select { cols(1..4) } - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun columnSelectorsMisc() { - val df = df.add { "year" from { 0 } } - // SampleStart - // by condition - df.select { cols { it.name().startsWith("year") } } - df.select { nameStartsWith("year") } - - // by type - df.select { colsOf() } - - // by type with condition - df.select { colsOf { it.countDistinct() > 5 } } - - // all top-level columns - df.select { all() } - - // first/last n columns - df.select { take(2) } - df.select { takeLast(2) } - - // all except first/last n columns - df.select { drop(2) } - df.select { dropLast(2) } - - // find the first column satisfying the condition - df.select { first { it.name.startsWith("year") } } - - // find the last column inside a column group satisfying the condition - df.select { - colGroup("name").lastCol { it.name().endsWith("Name") } - } - - // traversal of columns at any depth from here excluding ColumnGroups - df.select { colsAtAnyDepth().filter { !it.isColumnGroup() } } - - // traversal of columns at any depth from here including ColumnGroups - df.select { colsAtAnyDepth() } - - // traversal of columns at any depth with condition - df.select { colsAtAnyDepth().filter { it.name().contains(":") } } - - // traversal of columns at any depth to find columns of given type - df.select { colsAtAnyDepth().colsOf() } - - // all columns except given column set - df.select { allExcept { colsOf() } } - - // union of column sets - df.select { take(2) and col(3) } - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun columnSelectorsModifySet() { - // SampleStart - // first/last n value- and frame columns in column set - df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.take(3) } - df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.takeLast(3) } - - // all except first/last n value- and frame columns in column set - df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.drop(3) } - df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.dropLast(3) } - - // filter column set by condition - df.select { colsAtAnyDepth().filter { !it.isColumnGroup() && it.name().startsWith("year") } } - - // exclude columns from column set - df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.except { age } } - - // keep only unique columns - df.select { (colsOf() and age).distinct() } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun forRows_properties() { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Modify.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Modify.kt index 274937e930..efa3a5a581 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Modify.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Modify.kt @@ -35,9 +35,6 @@ import org.jetbrains.kotlinx.dataframe.api.default import org.jetbrains.kotlinx.dataframe.api.dropNulls import org.jetbrains.kotlinx.dataframe.api.explode import org.jetbrains.kotlinx.dataframe.api.fill -import org.jetbrains.kotlinx.dataframe.api.fillNA -import org.jetbrains.kotlinx.dataframe.api.fillNaNs -import org.jetbrains.kotlinx.dataframe.api.fillNulls import org.jetbrains.kotlinx.dataframe.api.filter import org.jetbrains.kotlinx.dataframe.api.flatten import org.jetbrains.kotlinx.dataframe.api.gather @@ -100,7 +97,6 @@ import org.jetbrains.kotlinx.dataframe.api.update import org.jetbrains.kotlinx.dataframe.api.where import org.jetbrains.kotlinx.dataframe.api.with import org.jetbrains.kotlinx.dataframe.api.withNull -import org.jetbrains.kotlinx.dataframe.api.withZero import org.jetbrains.kotlinx.dataframe.explainer.TransformDataFrameExpressions import org.jetbrains.kotlinx.dataframe.impl.api.mapNotNullValues import org.jetbrains.kotlinx.dataframe.io.readJson @@ -295,32 +291,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun fillNulls() { - // SampleStart - df.fillNulls { colsOf() }.with { -1 } - // same as - df.update { colsOf() }.where { it == null }.with { -1 } - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun fillNaNs() { - // SampleStart - df.fillNaNs { colsOf() }.withZero() - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun fillNA() { - // SampleStart - df.fillNA { weight }.with { -1 } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun move() { diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAllColumnsOfGroup_properties.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAllColumnsOfGroup_properties.html new file mode 100644 index 0000000000..26bd65fadb --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAllColumnsOfGroup_properties.html @@ -0,0 +1,511 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.fillNA.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAllExcept.html similarity index 60% rename from docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.fillNA.html rename to docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAllExcept.html index 2acbd82dd7..bf549bf28c 100644 --- a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.fillNA.html +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAllExcept.html @@ -177,24 +177,9 @@ -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
+

-
-
- Step 1: Update -
- -

DataFrame [7 x 5]

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAllTopLevel.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAllTopLevel.html new file mode 100644 index 0000000000..bf549bf28c --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAllTopLevel.html @@ -0,0 +1,516 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsArithmetic_properties.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsArithmetic_properties.html new file mode 100644 index 0000000000..03455b8d28 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsArithmetic_properties.html @@ -0,0 +1,510 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthByType.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthByType.html new file mode 100644 index 0000000000..26bd65fadb --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthByType.html @@ -0,0 +1,511 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthExcludingGroups.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthExcludingGroups.html new file mode 100644 index 0000000000..ccae0ecf36 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthExcludingGroups.html @@ -0,0 +1,515 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthFromGroup_properties.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthFromGroup_properties.html new file mode 100644 index 0000000000..26bd65fadb --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthFromGroup_properties.html @@ -0,0 +1,511 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.fillNaNs.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthIncludingGroups.html similarity index 60% rename from docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.fillNaNs.html rename to docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthIncludingGroups.html index 7f0430da40..0f35808e18 100644 --- a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.fillNaNs.html +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthIncludingGroups.html @@ -177,24 +177,9 @@ -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
+

-
-
- Step 1: Update -
- -

DataFrame [7 x 5]

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthWithCondition.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthWithCondition.html new file mode 100644 index 0000000000..15c5086362 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsAtAnyDepthWithCondition.html @@ -0,0 +1,511 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByColumnName.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByColumnName.html new file mode 100644 index 0000000000..42e812bc09 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByColumnName.html @@ -0,0 +1,512 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByColumnNameIt_properties.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByColumnNameIt_properties.html new file mode 100644 index 0000000000..42e812bc09 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByColumnNameIt_properties.html @@ -0,0 +1,512 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByColumnPath_properties.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByColumnPath_properties.html new file mode 100644 index 0000000000..24f173685f --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByColumnPath_properties.html @@ -0,0 +1,510 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByCondition.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByCondition.html new file mode 100644 index 0000000000..affed8440d --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByCondition.html @@ -0,0 +1,510 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByType.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByType.html new file mode 100644 index 0000000000..7e68ab6653 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByType.html @@ -0,0 +1,511 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByTypeWithCondition.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByTypeWithCondition.html new file mode 100644 index 0000000000..6d1603f437 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsByTypeWithCondition.html @@ -0,0 +1,510 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsColumnRange_properties.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsColumnRange_properties.html new file mode 100644 index 0000000000..d4e328baa3 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsColumnRange_properties.html @@ -0,0 +1,513 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsConverted_properties.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsConverted_properties.html new file mode 100644 index 0000000000..36e7f60bb7 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsConverted_properties.html @@ -0,0 +1,510 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsDf.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsDf.html new file mode 100644 index 0000000000..bf549bf28c --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsDf.html @@ -0,0 +1,516 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsDrop.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsDrop.html new file mode 100644 index 0000000000..3adead57b1 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsDrop.html @@ -0,0 +1,512 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsDropLast.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsDropLast.html new file mode 100644 index 0000000000..e147178a7a --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsDropLast.html @@ -0,0 +1,514 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsFirst.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsFirst.html new file mode 100644 index 0000000000..b42412cc42 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsFirst.html @@ -0,0 +1,510 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsLastInGroup.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsLastInGroup.html new file mode 100644 index 0000000000..3096cbff0b --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsLastInGroup.html @@ -0,0 +1,510 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyDistinct.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyDistinct.html new file mode 100644 index 0000000000..affed8440d --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyDistinct.html @@ -0,0 +1,510 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyDrop.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyDrop.html new file mode 100644 index 0000000000..3adead57b1 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyDrop.html @@ -0,0 +1,512 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyDropLast.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyDropLast.html new file mode 100644 index 0000000000..de75b2b1b2 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyDropLast.html @@ -0,0 +1,512 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyExcept.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyExcept.html new file mode 100644 index 0000000000..6d9d6a3c9b --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyExcept.html @@ -0,0 +1,514 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyFilter.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyFilter.html new file mode 100644 index 0000000000..affed8440d --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyFilter.html @@ -0,0 +1,510 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyTake.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyTake.html new file mode 100644 index 0000000000..de75b2b1b2 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyTake.html @@ -0,0 +1,512 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyTakeLast.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyTakeLast.html new file mode 100644 index 0000000000..3adead57b1 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsModifyTakeLast.html @@ -0,0 +1,512 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsTake.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsTake.html new file mode 100644 index 0000000000..d4e328baa3 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsTake.html @@ -0,0 +1,513 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsTakeLast.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsTakeLast.html new file mode 100644 index 0000000000..76ebe04cda --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsTakeLast.html @@ -0,0 +1,511 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsTwoColumns_properties.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsTwoColumns_properties.html new file mode 100644 index 0000000000..d4e328baa3 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsTwoColumns_properties.html @@ -0,0 +1,513 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUnion.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUnion.html new file mode 100644 index 0000000000..082791040d --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUnion.html @@ -0,0 +1,514 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageFillNaNs.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageFillNaNs.html new file mode 100644 index 0000000000..9bb95a827b --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageFillNaNs.html @@ -0,0 +1,514 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageFillNaNsDf.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageFillNaNsDf.html new file mode 100644 index 0000000000..110a94bce3 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageFillNaNsDf.html @@ -0,0 +1,514 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageGather.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageGather.html new file mode 100644 index 0000000000..5a6a5d1937 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageGather.html @@ -0,0 +1,517 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageGroup.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageGroup.html new file mode 100644 index 0000000000..1311456376 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageGroup.html @@ -0,0 +1,517 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageMove.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageMove.html new file mode 100644 index 0000000000..1b8c6fec13 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageMove.html @@ -0,0 +1,515 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageRemove.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageRemove.html new file mode 100644 index 0000000000..3c7af7e3f0 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageRemove.html @@ -0,0 +1,514 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageSelect.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageSelect.html new file mode 100644 index 0000000000..7ebed9fcdc --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageSelect.html @@ -0,0 +1,513 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageUpdate.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageUpdate.html new file mode 100644 index 0000000000..4d8252afc9 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsUsageUpdate.html @@ -0,0 +1,516 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsWithNewName_properties.html b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsWithNewName_properties.html new file mode 100644 index 0000000000..7b1e338061 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnSelectorsWithNewName_properties.html @@ -0,0 +1,512 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnsSelectorByIndex.html b/docs/StardustDocs/resources/api/columnSelectors/columnsSelectorByIndex.html new file mode 100644 index 0000000000..b42412cc42 --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnsSelectorByIndex.html @@ -0,0 +1,510 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnsSelectorByIndexRange.html b/docs/StardustDocs/resources/api/columnSelectors/columnsSelectorByIndexRange.html new file mode 100644 index 0000000000..ffb6bebd6f --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnsSelectorByIndexRange.html @@ -0,0 +1,513 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/columnSelectors/columnsSelectorBySeveralIndices.html b/docs/StardustDocs/resources/api/columnSelectors/columnsSelectorBySeveralIndices.html new file mode 100644 index 0000000000..082791040d --- /dev/null +++ b/docs/StardustDocs/resources/api/columnSelectors/columnsSelectorBySeveralIndices.html @@ -0,0 +1,514 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/fill/fillDf.html b/docs/StardustDocs/resources/api/fill/fillDf.html new file mode 100644 index 0000000000..02887a4d63 --- /dev/null +++ b/docs/StardustDocs/resources/api/fill/fillDf.html @@ -0,0 +1,511 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/fill/fillNA.html b/docs/StardustDocs/resources/api/fill/fillNA.html new file mode 100644 index 0000000000..375a0b529a --- /dev/null +++ b/docs/StardustDocs/resources/api/fill/fillNA.html @@ -0,0 +1,511 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/fill/fillNaNs.html b/docs/StardustDocs/resources/api/fill/fillNaNs.html new file mode 100644 index 0000000000..01f2d93d4f --- /dev/null +++ b/docs/StardustDocs/resources/api/fill/fillNaNs.html @@ -0,0 +1,511 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/fill/fillNulls.html b/docs/StardustDocs/resources/api/fill/fillNulls.html new file mode 100644 index 0000000000..1a44cf4e8e --- /dev/null +++ b/docs/StardustDocs/resources/api/fill/fillNulls.html @@ -0,0 +1,511 @@ + + + + + +
+ +

+ + + diff --git a/docs/StardustDocs/resources/api/pivot/pivotInward_properties.html b/docs/StardustDocs/resources/api/pivot/pivotInward_properties.html index 16700b2fb1..77e6e65e48 100644 --- a/docs/StardustDocs/resources/api/pivot/pivotInward_properties.html +++ b/docs/StardustDocs/resources/api/pivot/pivotInward_properties.html @@ -459,7 +459,7 @@ /**/ diff --git a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectors.html b/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectors.html deleted file mode 100644 index 189fd2e15f..0000000000 --- a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectors.html +++ /dev/null @@ -1,935 +0,0 @@ - - - - - -
- df.select { it.name } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 1 -
- -

-
-
-
-
- df.select { name } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 1 -
- -

-
-
-
-
- df.select { name.firstName } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 1 -
- -

-
-
-
-
- df.select { name named "Full Name" } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 1 -
- -

-
-
-
-
- df.select { name.firstName.map { it.lowercase() } } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 1 -
- -

-
-
-
-
- df.select { 2021 - age } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 1 -
- -

-
-
-
-
- df.select { name and age } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 2 -
- -

-
-
-
-
- df.select { name..age } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 2 -
- -

-
-
-
-
- df.select { name.allCols() } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 2 -
- -

-
-
-
-
- df.select { name.colsAtAnyDepth().filter { !it.isColumnGroup() } } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 2 -
- -

-
-
-
- - - diff --git a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectorsMisc.html b/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectorsMisc.html deleted file mode 100644 index 13b100d45c..0000000000 --- a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectorsMisc.html +++ /dev/null @@ -1,1278 +0,0 @@ - - - - - -
- df.add { "year" from { 0 } } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
-
-
- df.select { cols { it.name().startsWith("year") } } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 1 -
- -

-
-
-
-
- df.select { nameStartsWith("year") } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 1 -
- -

-
-
-
-
- df.select { colsOf<String>() } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 0, columnsCount = 0 -
- -

-
-
-
-
- df.select { colsOf<String?> { it.countDistinct() > 5 } } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 1 -
- -

-
-
-
-
- df.select { all() } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
-
-
- df.select { take(2) } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 2 -
- -

-
-
-
-
- df.select { takeLast(2) } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 2 -
- -

-
-
-
-
- df.select { drop(2) } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 4 -
- -

-
-
-
-
- df.select { dropLast(2) } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 4 -
- -

-
-
-
-
- df.select { first { it.name.startsWith("year") } } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 1 -
- -

-
-
-
-
- df.select { - colGroup("name").lastCol { it.name().endsWith(... -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 1 -
- -

-
-
-
-
- df.select { colsAtAnyDepth().filter { !it.isColumnGroup() } } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 7 -
- -

-
-
-
-
- df.select { colsAtAnyDepth() } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 8 -
- -

-
-
-
-
- df.select { colsAtAnyDepth().filter { it.name().contains(":") } } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 0, columnsCount = 0 -
- -

-
-
-
-
- df.select { colsAtAnyDepth().colsOf<String>() } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 2 -
- -

-
-
-
-
- df.select { allExcept { colsOf<String>() } } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
-
-
- df.select { take(2) and col(3) } -
- Input DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 3 -
- -

-
-
-
- - - diff --git a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectorsModifySet.html b/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectorsModifySet.html deleted file mode 100644 index 43f8e45df0..0000000000 --- a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectorsModifySet.html +++ /dev/null @@ -1,824 +0,0 @@ - - - - - -
- df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.take(3) } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 3 -
- -

-
-
-
-
- df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.takeLast(3... -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 3 -
- -

-
-
-
-
- df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.drop(3) } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 3 -
- -

-
-
-
-
- df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.dropLast(3... -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 3 -
- -

-
-
-
-
- df.select { colsAtAnyDepth().filter { !it.isColumnGroup() && it.name()... -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 0, columnsCount = 0 -
- -

-
-
-
-
- df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.except { a... -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
-
-
- df.select { (colsOf<Int>() and age).distinct() } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 1 -
- -

-
-
-
- - - diff --git a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectorsUsages.html b/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectorsUsages.html deleted file mode 100644 index 51c29593cc..0000000000 --- a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectorsUsages.html +++ /dev/null @@ -1,909 +0,0 @@ - - - - - -
- df.select { age and name } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 2 -
- -

-
-
-
-
- df.fillNaNs { colsAtAnyDepth().colsOf<Double>() }.withZero() -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Step 1: Update -
- -

DataFrame [7 x 5]

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
-
-
- df.remove { cols { it.hasNulls() } } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 3 -
- -

-
-
-
-
- df.into { "nameless" } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 2 -
- -

-
-
-
-
- df.update { city }.notNull { it.lowercase() } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Step 1: Update -
- -

DataFrame [7 x 5]

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
-
-
- df.gather { colsOf<Number>() }.into("key", "value") -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Step 1: Gather -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
-
-
- df.after { city } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 6 -
- -

-
-
-
- - - diff --git a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnsSelectorByIndices.html b/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnsSelectorByIndices.html deleted file mode 100644 index 4237b6021a..0000000000 --- a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnsSelectorByIndices.html +++ /dev/null @@ -1,676 +0,0 @@ - - - - - -
- df.select { col(2) } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 1 -
- -

-
-
-
-
- df.select { cols(0, 1, 3) } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 3 -
- -

-
-
-
-
- df.select { cols(1..4) } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 4 -
- -

-
-
-
- - - diff --git a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.fillNulls.html b/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.fillNulls.html deleted file mode 100644 index 10d384ef0a..0000000000 --- a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.fillNulls.html +++ /dev/null @@ -1,702 +0,0 @@ - - - - - -
- df.fillNulls { colsOf<Int?>() }.with { -1 } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Step 1: Update -
- -

DataFrame [7 x 5]

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
-
-
- df.update { colsOf<Int?>() }.where { it == null }.with { -1 } -
- Input DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
- Step 1: Update -
- -

DataFrame [7 x 5]

-
-
- Step 2: Update -
- -

DataFrame [7 x 5]

-
-
- Output DataFrame: rowsCount = 7, columnsCount = 5 -
- -

-
-
-
- - - diff --git a/docs/StardustDocs/topics/ColumnSelectors.md b/docs/StardustDocs/topics/ColumnSelectors.md index facb626c3a..531c671428 100644 --- a/docs/StardustDocs/topics/ColumnSelectors.md +++ b/docs/StardustDocs/topics/ColumnSelectors.md @@ -1,25 +1,95 @@ [//]: # (title: Column selectors) - + [`DataFrame`](DataFrame.md) provides a DSL for selecting an arbitrary set of columns: the Columns Selection DSL. +Unless stated otherwise, the examples on this page use the following dataframe: + + + +```kotlin +df +``` + + + + Column selectors are used in many operations: - + ```kotlin df.select { age and name } -df.fillNaNs { colsAtAnyDepth().colsOf() }.withZero() +``` + + + + + + +```kotlin df.remove { cols { it.hasNulls() } } +``` + + + + + + +```kotlin df.group { cols { it.data != name } }.into { "nameless" } +``` + + + + + + +```kotlin df.update { city }.notNull { it.lowercase() } +``` + + + + + + +```kotlin df.gather { colsOf() }.into("key", "value") +``` + + + + + + +```kotlin df.move { name.firstName and name.lastName }.after { city } ``` - + + +For the `fillNaNs` example, the following dataframe is used: + + + +```kotlin +dfWithNaNs +``` + + + + + + +```kotlin +dfWithNaNs.fillNaNs { colsAtAnyDepth().colsOf() }.withZero() +``` + + + #### Full DSL Grammar {collapsible="true"} @@ -421,176 +491,486 @@ It's extremely useful when you want to create a new column based on existing col **Select columns by name:** - + ```kotlin // by column name df.select { it.name } +``` + + + + +```kotlin +// by column name +df.select { it["name"] } +``` + + + + +same as + + + +```kotlin +// by column name df.select { name } +``` + + + + + + + + +```kotlin // by column path df.select { name.firstName } +``` + + + + +```kotlin +// by column path +df.select { it["name"]["firstName"] } // same as df.select { "name"["firstName"] } +``` + + + + + + + + +```kotlin // with a new name df.select { name named "Full Name" } +``` + + + +```kotlin +// with a new name +df.select { "name" named "Full Name" } +``` + + + + + + + + + +```kotlin // converted df.select { name.firstName.map { it.lowercase() } } +``` -// column arithmetics -df.select { 2021 - age } + + -// two columns -df.select { name and age } +```kotlin +// converted +df.select { "name"["firstName"]().map { it.lowercase() } } +``` -// range of columns -df.select { name..age } + + + -// all columns of ColumnGroup -df.select { name.allCols() } + + + -// traversal of columns at any depth from here excluding ColumnGroups -df.select { name.colsAtAnyDepth().filter { !it.isColumnGroup() } } +```kotlin +// column arithmetics +df.select { 2021 - age } ``` ```kotlin -// by column name -df.select { it["name"] } +// column arithmetics +df.select { 2021 - "age"() } +``` -// by column path -df.select { it["name"]["firstName"] } -df.select { "name"["firstName"] } + + + -// with a new name -df.select { "name" named "Full Name" } + + + -// converted -df.select { "name"["firstName"]().map { it.uppercase() } } +```kotlin +// two columns +df.select { name and age } +``` -// column arithmetics -df.select { 2021 - "age"() } + + +```kotlin // two columns df.select { "name" and "age" } +``` + + + + + + + + + +```kotlin +// range of columns +df.select { name..age } +``` + + + -// by range of names +```kotlin +// range of columns df.select { "name".."age" } +``` + + + + + + + + +```kotlin +// all columns of ColumnGroup +df.select { name.allCols() } +``` + + + + +```kotlin // all columns of ColumnGroup df.select { "name".allCols() } +``` + + + + + + + + +```kotlin +// traversal of columns at any depth from here excluding ColumnGroups +df.select { name.colsAtAnyDepth().filter { !it.isColumnGroup() } } +``` + + + + +```kotlin // traversal of columns at any depth from here excluding ColumnGroups df.select { "name".colsAtAnyDepth().filter { !it.isColumnGroup() } } ``` - + **Select columns by column index:** - + ```kotlin // by index df.select { col(2) } +``` + + + + + +```kotlin // by several indices df.select { cols(0, 1, 3) } +``` + + + + + +```kotlin // by range of indices df.select { cols(1..4) } ``` - + **Other column selectors:** - + ```kotlin // by condition -df.select { cols { it.name().startsWith("year") } } -df.select { nameStartsWith("year") } +df.select { cols { it.name().startsWith("a") } } +``` + + +same as + + + +```kotlin +// by condition +df.select { nameStartsWith("a") } +``` + + + + + + + +```kotlin // by type -df.select { colsOf() } +df.select { colsOf() } +``` + + + + + +```kotlin // by type with condition -df.select { colsOf { it.countDistinct() > 5 } } +df.select { colsOf { it.hasNulls() } } +``` + + + + + +```kotlin // all top-level columns df.select { all() } +``` + + + + + -// first/last n columns +```kotlin +// first n columns df.select { take(2) } +``` + + + + + + +```kotlin +// last n columns df.select { takeLast(2) } +``` + + + -// all except first/last n columns + + +```kotlin +// all except first n columns df.select { drop(2) } +``` + + + + + + +```kotlin +// all except last n columns df.select { dropLast(2) } +``` + + + + + +```kotlin // find the first column satisfying the condition -df.select { first { it.name.startsWith("year") } } +df.select { first { it.hasNulls() } } +``` + + + + + +```kotlin // find the last column inside a column group satisfying the condition df.select { colGroup("name").lastCol { it.name().endsWith("Name") } } +``` + + + + + +```kotlin // traversal of columns at any depth from here excluding ColumnGroups df.select { colsAtAnyDepth().filter { !it.isColumnGroup() } } +``` + + + + + +```kotlin // traversal of columns at any depth from here including ColumnGroups df.select { colsAtAnyDepth() } +``` + + + + + +```kotlin // traversal of columns at any depth with condition -df.select { colsAtAnyDepth().filter { it.name().contains(":") } } +df.select { colsAtAnyDepth().filter { it.name().contains("y") } } +``` + + + + + +```kotlin // traversal of columns at any depth to find columns of given type df.select { colsAtAnyDepth().colsOf() } +``` + + + + + +```kotlin // all columns except given column set df.select { allExcept { colsOf() } } +``` + + + + + +```kotlin // union of column sets df.select { take(2) and col(3) } ``` - + **Modify the set of selected columns:** - + ```kotlin -// first/last n value- and frame columns in column set +// first n value- and frame columns in column set df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.take(3) } +``` + + + + + + +```kotlin +// last n value- and frame columns in column set df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.takeLast(3) } +``` + + + -// all except first/last n value- and frame columns in column set + + +```kotlin +// all except first n value- and frame columns in column set df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.drop(3) } +``` + + + + + + +```kotlin +// all except last n value- and frame columns in column set df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.dropLast(3) } +``` + + + + + +```kotlin // filter column set by condition -df.select { colsAtAnyDepth().filter { !it.isColumnGroup() && it.name().startsWith("year") } } +df.select { colsAtAnyDepth().filter { !it.isColumnGroup() && it.name().startsWith("age") } } +``` + + + + + +```kotlin // exclude columns from column set df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.except { age } } +``` + + + + + +```kotlin // keep only unique columns df.select { (colsOf() and age).distinct() } ``` - + ### Column Resolvers @@ -613,5 +993,3 @@ df.group { colsAtAnyDepth().colsOf() } .into { it.path.dropLast(2) } ``` - **`ColumnSet`** — resolves to an ordered list of [`DataColumn`s](DataColumn.md). - - diff --git a/docs/StardustDocs/topics/_shadow_resources.md b/docs/StardustDocs/topics/_shadow_resources.md index 08f1ae858a..7b1b4c540f 100644 --- a/docs/StardustDocs/topics/_shadow_resources.md +++ b/docs/StardustDocs/topics/_shadow_resources.md @@ -8,6 +8,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -27,6 +76,11 @@ + + + + + @@ -96,6 +150,7 @@ + @@ -215,6 +270,8 @@ + + @@ -227,11 +284,6 @@ - - - - - @@ -242,7 +294,6 @@ - @@ -254,7 +305,6 @@ - @@ -306,9 +356,6 @@ - - - @@ -332,7 +379,6 @@ - @@ -347,12 +393,4 @@ - - - - - - - - - + \ No newline at end of file diff --git a/docs/StardustDocs/topics/fill.md b/docs/StardustDocs/topics/fill.md index 6055f7d8f1..73b43c6abd 100644 --- a/docs/StardustDocs/topics/fill.md +++ b/docs/StardustDocs/topics/fill.md @@ -1,54 +1,81 @@ [//]: # (title: fill) - + Replace missing values. **Related operations**: [](updateConvert.md) +The examples on this page use the following dataframe: + + + +```kotlin +df +``` + + + + ## fillNulls -Replaces `null` values with given value or expression. +Replaces `null` values with given value or expression. + +See also [dropNulls](drop.md#dropnulls), which removes rows with `null` values instead of replacing these values. See [column selectors](ColumnSelectors.md) for how to select the columns for this operation. ```kotlin -df.fillNulls { colsOf() }.with { -1 } -// same as -df.update { colsOf() }.where { it == null }.with { -1 } +df.fillNulls { weight }.with { -1.0 } ``` - +same as + + + +```kotlin +df.update { weight }.where { it == null }.with { -1.0 } +``` + + + + ## fillNaNs Replaces [`NaN` values](nanAndNa.md#nan) (`Double.NaN` and `Float.NaN`) with given value or expression. +See also [dropNaNs](drop.md#dropnans), which removes rows with [`NaN` values](nanAndNa.md#nan) +instead of replacing these values. + See [column selectors](ColumnSelectors.md) for how to select the columns for this operation. ```kotlin -df.fillNaNs { colsOf() }.withZero() +df.fillNaNs { weight }.withZero() ``` - + ## fillNA Replaces [`NA` values](nanAndNa.md#na) (`null`, `Double.NaN`, and `Float.NaN`) with given value or expression. +See also [dropNA](drop.md#dropna), which removes rows with [`NA` values](nanAndNa.md#na) +instead of replacing these values. + See [column selectors](ColumnSelectors.md) for how to select the columns for this operation. ```kotlin -df.fillNA { weight }.with { -1 } +df.fillNA { weight }.with { -1.0 } ``` - + diff --git a/samples/build.gradle.kts b/samples/build.gradle.kts index 200716beb8..4919cf3a46 100644 --- a/samples/build.gradle.kts +++ b/samples/build.gradle.kts @@ -114,9 +114,11 @@ korro { include("readSqlDatabases.md") include("info/*.md") include("columnArithmetics.md") + include("ColumnSelectors.md") include("groupBy.md") include("pivot.md") include("countDistinct.md") + include("fill.md") include("filter.md") include("count.md") include("valueCounts.md") diff --git a/samples/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/ColumnSelectorsSamples.kt b/samples/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/ColumnSelectorsSamples.kt new file mode 100644 index 0000000000..2de62c701e --- /dev/null +++ b/samples/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/ColumnSelectorsSamples.kt @@ -0,0 +1,548 @@ +package org.jetbrains.kotlinx.dataframe.samples.api + +import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.DataRow +import org.jetbrains.kotlinx.dataframe.annotations.DataSchema +import org.jetbrains.kotlinx.dataframe.api.after +import org.jetbrains.kotlinx.dataframe.api.cast +import org.jetbrains.kotlinx.dataframe.api.colsOf +import org.jetbrains.kotlinx.dataframe.api.dataFrameOf +import org.jetbrains.kotlinx.dataframe.api.distinct +import org.jetbrains.kotlinx.dataframe.api.drop +import org.jetbrains.kotlinx.dataframe.api.dropLast +import org.jetbrains.kotlinx.dataframe.api.fillNaNs +import org.jetbrains.kotlinx.dataframe.api.first +import org.jetbrains.kotlinx.dataframe.api.gather +import org.jetbrains.kotlinx.dataframe.api.group +import org.jetbrains.kotlinx.dataframe.api.into +import org.jetbrains.kotlinx.dataframe.api.isColumnGroup +import org.jetbrains.kotlinx.dataframe.api.map +import org.jetbrains.kotlinx.dataframe.api.minus +import org.jetbrains.kotlinx.dataframe.api.move +import org.jetbrains.kotlinx.dataframe.api.notNull +import org.jetbrains.kotlinx.dataframe.api.remove +import org.jetbrains.kotlinx.dataframe.api.select +import org.jetbrains.kotlinx.dataframe.api.take +import org.jetbrains.kotlinx.dataframe.api.takeLast +import org.jetbrains.kotlinx.dataframe.api.update +import org.jetbrains.kotlinx.dataframe.api.withZero +import org.jetbrains.kotlinx.dataframe.get +import org.jetbrains.kotlinx.dataframe.samples.DataFrameSampleHelper +import org.junit.Test + +class ColumnSelectorsSamples : DataFrameSampleHelper("columnSelectors", "api") { + @DataSchema + interface Name { + val firstName: String + val lastName: String + } + + @DataSchema + interface Measurements { + val weight: Double? + } + + @DataSchema + interface PersonWithWeight { + val name: DataRow + val measurements: DataRow + } + + private val dfWithNaNs: DataFrame = dataFrameOf( + "firstName", + "lastName", + "weight", + )( + "Alice", + "Cooper", + 54.0, + "Charlie", + "Daniels", + Double.NaN, + "Bob", + "Dylan", + null, + ).group { firstName and lastName }.into("name") + .group { weight }.into("measurements") + .cast() + + val df = peopleDf + + @Test + fun columnSelectorsDf() { + // SampleStart + df + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsUsageSelect() { + // SampleStart + df.select { age and name } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsUsageRemove() { + // SampleStart + df.remove { cols { it.hasNulls() } } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsUsageGroup() { + // SampleStart + df.group { cols { it.data != name } }.into { "nameless" } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsUsageUpdate() { + // SampleStart + df.update { city }.notNull { it.lowercase() } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsUsageGather() { + // SampleStart + df.gather { colsOf() }.into("key", "value") + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsUsageMove() { + // SampleStart + df.move { name.firstName and name.lastName }.after { city } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsUsageFillNaNsDf() { + // SampleStart + dfWithNaNs + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsUsageFillNaNs() { + // SampleStart + dfWithNaNs.fillNaNs { colsAtAnyDepth().colsOf() }.withZero() + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsByColumnNameIt_properties() { + // SampleStart + // by column name + df.select { it.name } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsByColumnNameIt_strings() { + // SampleStart + // by column name + df.select { it["name"] } + // SampleEnd + } + + @Test + fun columnSelectorsByColumnName() { + // SampleStart + // by column name + df.select { name } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsByColumnPath_properties() { + // SampleStart + // by column path + df.select { name.firstName } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsByColumnPath_strings() { + // SampleStart + // by column path + df.select { it["name"]["firstName"] } // same as df.select { "name"["firstName"] } + // SampleEnd + } + + @Test + fun columnSelectorsWithNewName_properties() { + // SampleStart + // with a new name + df.select { name named "Full Name" } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsWithNewName_strings() { + // SampleStart + // with a new name + df.select { "name" named "Full Name" } + // SampleEnd + } + + @Test + fun columnSelectorsConverted_properties() { + // SampleStart + // converted + df.select { name.firstName.map { it.lowercase() } } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsConverted_strings() { + // SampleStart + // converted + df.select { "name"["firstName"]().map { it.lowercase() } } + // SampleEnd + } + + @Test + fun columnSelectorsArithmetic_properties() { + // SampleStart + // column arithmetics + df.select { 2021 - age } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsArithmetic_strings() { + // SampleStart + // column arithmetics + df.select { 2021 - "age"() } + // SampleEnd + } + + @Test + fun columnSelectorsTwoColumns_properties() { + // SampleStart + // two columns + df.select { name and age } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsTwoColumns_strings() { + // SampleStart + // two columns + df.select { "name" and "age" } + // SampleEnd + } + + @Test + fun columnSelectorsColumnRange_properties() { + // SampleStart + // range of columns + df.select { name..age } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsColumnRange_strings() { + // SampleStart + // range of columns + df.select { "name".."age" } + // SampleEnd + } + + @Test + fun columnSelectorsAllColumnsOfGroup_properties() { + // SampleStart + // all columns of ColumnGroup + df.select { name.allCols() } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsAllColumnsOfGroup_strings() { + // SampleStart + // all columns of ColumnGroup + df.select { "name".allCols() } + // SampleEnd + } + + @Test + fun columnSelectorsAtAnyDepthFromGroup_properties() { + // SampleStart + // traversal of columns at any depth from here excluding ColumnGroups + df.select { name.colsAtAnyDepth().filter { !it.isColumnGroup() } } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsAtAnyDepthFromGroup_strings() { + // SampleStart + // traversal of columns at any depth from here excluding ColumnGroups + df.select { "name".colsAtAnyDepth().filter { !it.isColumnGroup() } } + // SampleEnd + } + + @Test + fun columnsSelectorByIndex() { + // SampleStart + // by index + df.select { col(2) } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnsSelectorBySeveralIndices() { + // SampleStart + // by several indices + df.select { cols(0, 1, 3) } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnsSelectorByIndexRange() { + // SampleStart + // by range of indices + df.select { cols(1..4) } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsByCondition() { + // SampleStart + // by condition + df.select { cols { it.name().startsWith("a") } } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsByName() { + // SampleStart + // by condition + df.select { nameStartsWith("a") } + // SampleEnd + } + + @Test + fun columnSelectorsByType() { + // SampleStart + // by type + df.select { colsOf() } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsByTypeWithCondition() { + // SampleStart + // by type with condition + df.select { colsOf { it.hasNulls() } } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsAllTopLevel() { + // SampleStart + // all top-level columns + df.select { all() } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsTake() { + // SampleStart + // first n columns + df.select { take(2) } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsTakeLast() { + // SampleStart + // last n columns + df.select { takeLast(2) } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsDrop() { + // SampleStart + // all except first n columns + df.select { drop(2) } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsDropLast() { + // SampleStart + // all except last n columns + df.select { dropLast(2) } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsFirst() { + // SampleStart + // find the first column satisfying the condition + df.select { first { it.hasNulls() } } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsLastInGroup() { + // SampleStart + // find the last column inside a column group satisfying the condition + df.select { + colGroup("name").lastCol { it.name().endsWith("Name") } + } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsAtAnyDepthExcludingGroups() { + // SampleStart + // traversal of columns at any depth from here excluding ColumnGroups + df.select { colsAtAnyDepth().filter { !it.isColumnGroup() } } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsAtAnyDepthIncludingGroups() { + // SampleStart + // traversal of columns at any depth from here including ColumnGroups + df.select { colsAtAnyDepth() } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsAtAnyDepthWithCondition() { + // SampleStart + // traversal of columns at any depth with condition + df.select { colsAtAnyDepth().filter { it.name().contains("y") } } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsAtAnyDepthByType() { + // SampleStart + // traversal of columns at any depth to find columns of given type + df.select { colsAtAnyDepth().colsOf() } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsAllExcept() { + // SampleStart + // all columns except given column set + df.select { allExcept { colsOf() } } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsUnion() { + // SampleStart + // union of column sets + df.select { take(2) and col(3) } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsModifyTake() { + // SampleStart + // first n value- and frame columns in column set + df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.take(3) } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsModifyTakeLast() { + // SampleStart + // last n value- and frame columns in column set + df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.takeLast(3) } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsModifyDrop() { + // SampleStart + // all except first n value- and frame columns in column set + df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.drop(3) } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsModifyDropLast() { + // SampleStart + // all except last n value- and frame columns in column set + df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.dropLast(3) } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsModifyFilter() { + // SampleStart + // filter column set by condition + df.select { colsAtAnyDepth().filter { !it.isColumnGroup() && it.name().startsWith("age") } } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsModifyExcept() { + // SampleStart + // exclude columns from column set + df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.except { age } } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun columnSelectorsModifyDistinct() { + // SampleStart + // keep only unique columns + df.select { (colsOf() and age).distinct() } + // SampleEnd + .saveDfHtmlSample() + } +} diff --git a/samples/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/FillSamples.kt b/samples/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/FillSamples.kt new file mode 100644 index 0000000000..cbe35eb181 --- /dev/null +++ b/samples/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/FillSamples.kt @@ -0,0 +1,74 @@ +package org.jetbrains.kotlinx.dataframe.samples.api + +import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.annotations.DataSchema +import org.jetbrains.kotlinx.dataframe.api.cast +import org.jetbrains.kotlinx.dataframe.api.dataFrameOf +import org.jetbrains.kotlinx.dataframe.api.fillNA +import org.jetbrains.kotlinx.dataframe.api.fillNaNs +import org.jetbrains.kotlinx.dataframe.api.fillNulls +import org.jetbrains.kotlinx.dataframe.api.update +import org.jetbrains.kotlinx.dataframe.api.where +import org.jetbrains.kotlinx.dataframe.api.with +import org.jetbrains.kotlinx.dataframe.api.withZero +import org.jetbrains.kotlinx.dataframe.samples.DataFrameSampleHelper +import org.junit.Test + +class FillSamples : DataFrameSampleHelper("fill", "api") { + @DataSchema + interface PersonWithWeight { + val name: String + val weight: Double? + } + + private val df: DataFrame = dataFrameOf( + "name", + "weight", + )( + "Alice", + 54.0, + "Charlie", + Double.NaN, + "Bob", + null, + ).cast() + + @Test + fun fillDf() { + // SampleStart + df + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun fillNulls() { + // SampleStart + df.fillNulls { weight }.with { -1.0 } + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun fillNullsAsUpdate() { + // SampleStart + df.update { weight }.where { it == null }.with { -1.0 } + // SampleEnd + } + + @Test + fun fillNaNs() { + // SampleStart + df.fillNaNs { weight }.withZero() + // SampleEnd + .saveDfHtmlSample() + } + + @Test + fun fillNA() { + // SampleStart + df.fillNA { weight }.with { -1.0 } + // SampleEnd + .saveDfHtmlSample() + } +}