diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/AccessApi.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/AccessApi.kt index 2302251a7c..cfb35a0d3e 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/AccessApi.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/AccessApi.kt @@ -9,11 +9,8 @@ import org.jetbrains.kotlinx.dataframe.documentation.AccessApi.AnyApiLinks * or deleted while wrangling. Kotlin, in contrast, is a statically typed language and all types are defined and verified * ahead of execution. That's why creating a flexible, handy, and, at the same time, safe API to a dataframe is tricky. * - * In `Kotlin DataFrame` we provide four different ways to access columns, and, while they're essentially different, they - * look pretty similar in the data wrangling DSL. These include: + * In `Kotlin DataFrame` we provide two different ways to access columns: * - [Extension Properties API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.ExtensionPropertiesApi] - * - [KProperties API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.KPropertiesApi] - * - [Column Accessors API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.ColumnAccessorsApi] * - [String API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.StringApi] * * For more information: [See Access APIs on the documentation website.](https://kotlin.github.io/dataframe/apilevels.html) @@ -23,8 +20,6 @@ internal interface AccessApi { /** * - [Extension Properties API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.ExtensionPropertiesApi] - * - [KProperties API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.KPropertiesApi] - * - [Column Accessors API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.ColumnAccessorsApi] * - [String API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.StringApi] */ interface AnyApiLinks @@ -59,20 +54,6 @@ internal interface AccessApi { * a variable that represents its name and type. * * For more information: [See Column Accessors API on the documentation website.](https://kotlin.github.io/dataframe/columnaccessorsapi.html) - * - * For example: - * ```kotlin - * val survived by column() - * val home by column() - * val age by column() - * val name by column() - * val lastName by column() - * - * DataFrame.read("titanic.csv") - * .add(lastName) { name().split(",").last() } - * .dropNulls { age } - * .filter { survived() && home().endsWith("NY") && age()!! in 10..20 } - * ``` */ interface ColumnAccessorsApi @@ -87,26 +68,6 @@ internal interface AccessApi { * The name and type of column should match the name and type of property, respectively. * * For more information: [See KProperties API on the documentation website.](https://kotlin.github.io/dataframe/kpropertiesapi.html) - * - * For example: - * ```kotlin - * data class Passenger( - * val survived: Boolean, - * val home: String, - * val age: Int, - * val lastName: String - * ) - * - * val passengers = DataFrame.read("titanic.csv") - * .add(Passenger::lastName) { "name"().split(",").last() } - * .dropNulls(Passenger::age) - * .filter { - * it[Passenger::survived] && - * it[Passenger::home].endsWith("NY") && - * it[Passenger::age] in 10..20 - * } - * .toListOf() - * ``` */ interface KPropertiesApi @@ -120,10 +81,15 @@ internal interface AccessApi { * * For more information: [See Extension Properties API on the documentation website.](https://kotlin.github.io/dataframe/extensionpropertiesapi.html) * - * For example: + * For example, in notebooks extension properties are generated from runtime data after the cell is executed: * ```kotlin * val df /* : AnyFrame */ = DataFrame.read("titanic.csv") * ``` + * ```kotlin + * df.add("lastName") { name.split(",").last() } + * .dropNulls { age } + * .filter { survived && home.endsWith("NY") && age in 10..20 } + * ``` */ interface ExtensionPropertiesApi diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/AccessApi.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/AccessApi.kt index e4122591de..d6911ede71 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/AccessApi.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/AccessApi.kt @@ -9,8 +9,7 @@ import org.jetbrains.kotlinx.dataframe.documentation.AccessApi.AnyApiLinks * or deleted while wrangling. Kotlin, in contrast, is a statically typed language and all types are defined and verified * ahead of execution. That's why creating a flexible, handy, and, at the same time, safe API to a dataframe is tricky. * - * In `Kotlin DataFrame` we provide four different ways to access columns, and, while they're essentially different, they - * look pretty similar in the data wrangling DSL. These include: + * In `Kotlin DataFrame` we provide two different ways to access columns: * @include [AnyApiLinks] * * For more information: {@include [DocumentationUrls.AccessApis]} @@ -21,8 +20,6 @@ internal interface AccessApi { /** * - {@include [ExtensionPropertiesApiLink]} - * - {@include [KPropertiesApiLink]} - * - {@include [ColumnAccessorsApiLink]} * - {@include [StringApiLink]} */ interface AnyApiLinks @@ -48,9 +45,6 @@ internal interface AccessApi { * a variable that represents its name and type. * * For more information: {@include [DocumentationUrls.AccessApis.ColumnAccessorsApi]} - * - * For example: {@comment This works if you include the test module when running KoDEx} - * @sample [org.jetbrains.kotlinx.dataframe.samples.api.ApiLevels.accessors3] */ interface ColumnAccessorsApi @@ -65,9 +59,6 @@ internal interface AccessApi { * The name and type of column should match the name and type of property, respectively. * * For more information: {@include [DocumentationUrls.AccessApis.KPropertiesApi]} - * - * For example: {@comment This works if you include the test module when running KoDEx} - * @sample [org.jetbrains.kotlinx.dataframe.samples.api.ApiLevels.kproperties1] */ interface KPropertiesApi @@ -81,8 +72,9 @@ internal interface AccessApi { * * For more information: {@include [DocumentationUrls.AccessApis.ExtensionPropertiesApi]} * - * For example: {@comment This works if you include the test module when running KoDEx} + * For example, in notebooks extension properties are generated from runtime data after the cell is executed: {@comment This works if you include the test module when running KoDEx} * @sample [org.jetbrains.kotlinx.dataframe.samples.api.ApiLevels.extensionProperties1] + * @sample [org.jetbrains.kotlinx.dataframe.samples.api.ApiLevels.extensionProperties2] */ interface ExtensionPropertiesApi 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 bec11df6ab..9b4ecf5bfc 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 @@ -6,10 +6,7 @@ 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.column -import org.jetbrains.kotlinx.dataframe.api.columnOf import org.jetbrains.kotlinx.dataframe.api.countDistinct -import org.jetbrains.kotlinx.dataframe.api.dataFrameOf import org.jetbrains.kotlinx.dataframe.api.distinct import org.jetbrains.kotlinx.dataframe.api.distinctBy import org.jetbrains.kotlinx.dataframe.api.drop @@ -37,13 +34,11 @@ 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.named 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 import org.jetbrains.kotlinx.dataframe.api.single -import org.jetbrains.kotlinx.dataframe.api.sortBy import org.jetbrains.kotlinx.dataframe.api.take import org.jetbrains.kotlinx.dataframe.api.takeLast import org.jetbrains.kotlinx.dataframe.api.takeWhile @@ -407,37 +402,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun namedAndRenameCol() { - // SampleStart - val unnamedCol = columnOf("Alice", "Bob") - val colRename = unnamedCol.rename("name") - val colNamed = columnOf("Alice", "Bob") named "name" - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun namedColumnWithoutValues() { - // SampleStart - val name by column() - val col = column("name") - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun colRefForTypedAccess() { - val df = dataFrameOf("name")("Alice", "Bob") - val name by column() - val col = column("name") - // SampleStart - df.filter { it[name].startsWith("A") } - df.sortBy { col } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun iterableApi() { @@ -570,41 +534,6 @@ class Access : TestBase() { // SampleEnd } - @Test - fun columnSelectors_kproperties() { - // SampleStart - // by column name - df.select { it[Person::name] } - df.select { (Person::name)() } - df.select { col(Person::name) } - - // by column path - df.select { it[Person::name][Name::firstName] } - df.select { Person::name[Name::firstName] } - - // with a new name - df.select { Person::name named "Full Name" } - - // converted - df.select { Person::name[Name::firstName].map { it.lowercase() } } - - // column arithmetics - df.select { 2021 - (Person::age)() } - - // two columns - df.select { Person::name and Person::age } - - // range of columns - df.select { Person::name..Person::age } - - // all columns of ColumnGroup - df.select { Person::name.allCols() } - - // traversal of columns at any depth from here excluding ColumnGroups - df.select { Person::name.colsAtAnyDepth().filter { !it.isColumnGroup() } } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun columnSelectors_strings() { @@ -688,11 +617,6 @@ class Access : TestBase() { colGroup("name").lastCol { it.name().endsWith("Name") } } - // find the single column inside a column group satisfying the condition - df.select { - Person::name.singleCol { it.name().startsWith("first") } - } - // traversal of columns at any depth from here excluding ColumnGroups df.select { colsAtAnyDepth().filter { !it.isColumnGroup() } } @@ -700,7 +624,7 @@ class Access : TestBase() { df.select { colsAtAnyDepth() } // traversal of columns at any depth with condition - df.select { colsAtAnyDepth().filter() { it.name().contains(":") } } + df.select { colsAtAnyDepth().filter { it.name().contains(":") } } // traversal of columns at any depth to find columns of given type df.select { colsAtAnyDepth().colsOf() } diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Analyze.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Analyze.kt index 19457121da..e361d91868 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Analyze.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Analyze.kt @@ -8,8 +8,6 @@ import org.jetbrains.kotlinx.dataframe.api.asGroupBy import org.jetbrains.kotlinx.dataframe.api.asNumbers import org.jetbrains.kotlinx.dataframe.api.cast import org.jetbrains.kotlinx.dataframe.api.colsOf -import org.jetbrains.kotlinx.dataframe.api.column -import org.jetbrains.kotlinx.dataframe.api.columnGroup import org.jetbrains.kotlinx.dataframe.api.columnOf import org.jetbrains.kotlinx.dataframe.api.concat import org.jetbrains.kotlinx.dataframe.api.count @@ -445,31 +443,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun columnsFor_accessors() { - // SampleStart - val name by columnGroup() - val firstName by name.column() - val lastName by name.column() - val age by column() - val weight by column() - - df.minFor { colsOf() } - - df.maxFor { firstName and age } - // or - df.maxFor(firstName, lastName) - - df.sumFor { age and weight } - // or - df.sum(age, weight) - - df.mean { cols(1, 3).asNumbers() } - df.median<_, String> { name.allCols().cast() } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun columnsFor_strings() { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/ApiLevels.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/ApiLevels.kt index 429638923e..140466e6a4 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/ApiLevels.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/ApiLevels.kt @@ -3,14 +3,11 @@ package org.jetbrains.kotlinx.dataframe.samples.api import org.jetbrains.kotlinx.dataframe.DataFrame -import org.jetbrains.kotlinx.dataframe.annotations.ColumnName import org.jetbrains.kotlinx.dataframe.annotations.DataSchema import org.jetbrains.kotlinx.dataframe.api.add import org.jetbrains.kotlinx.dataframe.api.cast -import org.jetbrains.kotlinx.dataframe.api.column import org.jetbrains.kotlinx.dataframe.api.dropNulls import org.jetbrains.kotlinx.dataframe.api.filter -import org.jetbrains.kotlinx.dataframe.api.toListOf import org.jetbrains.kotlinx.dataframe.explainer.TransformDataFrameExpressions import org.jetbrains.kotlinx.dataframe.io.read import org.junit.Ignore @@ -34,91 +31,6 @@ class ApiLevels { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun accessors1() { - // SampleStart - val survived by column() // accessor for Boolean column with name 'survived' - val home by column() - val age by column() - val name by column() - val lastName by column() - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun accessors2() { - val survived by column() - val home by column() - val age by column() - val name by column() - val lastName by column() - // SampleStart - - DataFrame.read("titanic.csv") - .add(lastName) { name().split(",").last() } - .dropNulls { age } - .filter { survived() && home().endsWith("NY") && age()!! in 10..20 } - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun accessors3() { - // SampleStart - val survived by column() - val home by column() - val age by column() - val name by column() - val lastName by column() - - DataFrame.read("titanic.csv") - .add(lastName) { name().split(",").last() } - .dropNulls { age } - .filter { survived() && home().endsWith("NY") && age()!! in 10..20 } - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun kproperties1() { - // SampleStart - data class Passenger( - val survived: Boolean, - val home: String, - val age: Int, - val lastName: String - ) - - val passengers = DataFrame.read("titanic.csv") - .add(Passenger::lastName) { "name"().split(",").last() } - .dropNulls(Passenger::age) - .filter { - it[Passenger::survived] && - it[Passenger::home].endsWith("NY") && - it[Passenger::age] in 10..20 - } - .toListOf() - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun kproperties2() { - // SampleStart - data class Passenger( - @ColumnName("survived") val isAlive: Boolean, - @ColumnName("home") val city: String, - val name: String - ) - - val passengers = DataFrame.read("titanic.csv") - .filter { it[Passenger::city].endsWith("NY") } - .toListOf() - // SampleEnd - } - @DataSchema interface TitanicPassenger { val survived: Boolean diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Create.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Create.kt index 7f446ac718..c0fc075988 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Create.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Create.kt @@ -51,32 +51,6 @@ class Create : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun columnAccessorsUsage() { - // SampleStart - val age by column() - - // Access fourth cell in the "age" column of dataframe `df`. - // This expression returns `Int` because variable `age` has `ColumnAccessor` type. - // If dataframe `df` has no column "age" or column "age" has type which is incompatible with `Int`, - // runtime exception will be thrown. - df[age][3] + 5 - - // Access first cell in the "age" column of dataframe `df`. - df[0][age] * 2 - - // Returns new dataframe sorted by age column (ascending) - df.sortBy(age) - - // Returns new dataframe with the column "year of birth" added - df.add("year of birth") { 2021 - age } - - // Returns new dataframe containing only rows with age > 30 - df.filter { age > 30 } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun columnAccessorMap() { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/JoinWith.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/JoinWith.kt index e105fd2b63..e86de2b9c2 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/JoinWith.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/JoinWith.kt @@ -144,7 +144,7 @@ class JoinWith : TestBase() { cellRenderer = renderer, configuration = SamplesDisplayConfiguration.copy( cellFormatter = { row, col -> - val value = row[col] + val value = col[row] if (value is ColoredValue<*>) { background(value.backgroundColor) and textColor(value.textColor) } else { 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 ed57a72f5c..971996dcaf 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 @@ -10,6 +10,7 @@ import org.jetbrains.kotlinx.dataframe.alsoDebug import org.jetbrains.kotlinx.dataframe.annotations.DataSchema import org.jetbrains.kotlinx.dataframe.api.ParserOptions import org.jetbrains.kotlinx.dataframe.api.add +import org.jetbrains.kotlinx.dataframe.api.addAll import org.jetbrains.kotlinx.dataframe.api.after import org.jetbrains.kotlinx.dataframe.api.asColumn import org.jetbrains.kotlinx.dataframe.api.asFrame @@ -854,7 +855,7 @@ class Modify : TestBase() { // SampleStart val score by columnOf(4, 3, 5, 2, 1, 3, 5) - df.add(score) + df.addAll(score) df + score // SampleEnd } @@ -865,7 +866,7 @@ class Modify : TestBase() { val df1 = df.select { name named "name2" } val df2 = df.select { age named "age2" } // SampleStart - df.add(df1, df2) + df.addAll(df1, df2) // SampleEnd } @@ -890,7 +891,7 @@ class Modify : TestBase() { val personWithCityInfo = df.add { val cityInfo = city.map { queryCityInfo(it) } "cityInfo" { - cityInfo.map { it.location } into CityInfo::location + cityInfo.map { it.location } into "location" cityInfo.map { it.population } into "population" } } @@ -905,7 +906,7 @@ class Modify : TestBase() { val personWithCityInfo = df.add { val cityInfo = "city"().map { queryCityInfo(it) } "cityInfo" { - cityInfo.map { it.location } into CityInfo::location + cityInfo.map { it.location } into "location" cityInfo.map { it.population } into "population" } } @@ -918,8 +919,8 @@ class Modify : TestBase() { fun addMany_properties() { // SampleStart df.add { - "year of birth" from 2021 - age - age gt 18 into "is adult" + "year of birth" from { 2021 - age } + expr { age > 18 } into "is adult" "details" { name.lastName.map { it.length } into "last name length" "full name" from { name.firstName + " " + name.lastName } @@ -933,8 +934,8 @@ class Modify : TestBase() { fun addMany_strings() { // SampleStart df.add { - "year of birth" from 2021 - "age"() - "age"() gt 18 into "is adult" + "year of birth" from { 2021 - "age"() } + expr { "age"() > 18 } into "is adult" "details" { "name"["lastName"]().map { it.length } into "last name length" "full name" from { "name"["firstName"]() + " " + "name"["lastName"]() } @@ -988,8 +989,8 @@ class Modify : TestBase() { fun mapMany_properties() { // SampleStart df.mapToFrame { - "year of birth" from 2021 - age - age gt 18 into "is adult" + "year of birth" from { 2021 - age } + expr { age > 18 } into "is adult" name.lastName.map { it.length } into "last name length" "full name" from { name.firstName + " " + name.lastName } +city @@ -1002,8 +1003,8 @@ class Modify : TestBase() { fun mapMany_strings() { // SampleStart df.mapToFrame { - "year of birth" from 2021 - "age"() - "age"() gt 18 into "is adult" + "year of birth" from { 2021 - "age"() } + expr { "age"() > 18 } into "is adult" "name"["lastName"]().map { it.length } into "last name length" "full name" from { "name"["firstName"]() + " " + "name"["lastName"]() } +"city" @@ -1051,16 +1052,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun flatten_KProperties() { - // SampleStart - // name.firstName -> firstName - // name.lastName -> lastName - df.flatten(df::name) - // SampleEnd - } - @Test @TransformDataFrameExpressions fun flattenAll() { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Schemas.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Schemas.kt index c625a8657d..1a45a3d01c 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Schemas.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Schemas.kt @@ -88,7 +88,7 @@ class Schemas { // SampleEnd } - fun DataFrame.countAdults() = count { it[Person::age] > 18 } + fun DataFrame.countAdults() = count { it.age > 18 } @Test @TransformDataFrameExpressions @@ -103,7 +103,7 @@ class Schemas { val df = dataFrameOf("name", "age", "weight")( "Merton, Alice", "15", 60.0, "Marley, Bob", "20", 73.5, - ).split { "name"() }.inward("firstName", "lastName") + ).split { "name"() }.by(",").inward("firstName", "lastName") val persons = df.cast().toList() // SampleEnd 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 index 29b25d457e..fd2a5fe8da 100644 --- 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 @@ -372,9 +372,7 @@
- df.select { - Person::name.singleCol { it.name().startsWith("first") } - } + df.select { colsAtAnyDepth().filter { !it.isColumnGroup() } }
Input DataFrame: rowsCount = 7, columnsCount = 6
@@ -382,7 +380,7 @@

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

@@ -390,7 +388,7 @@

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

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

@@ -406,32 +404,16 @@

- df.select { colsAtAnyDepth() } + df.select { colsAtAnyDepth().filter { it.name().contains(":") } }
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 -
+

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

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

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

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

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

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

@@ -1157,6 +1139,12 @@ /**/ @@ -1179,6 +1167,9 @@ /**/ call_DataFrame(function() { DataFrame.renderTable(29) }); @@ -1234,7 +1215,9 @@ call_DataFrame(function() { DataFrame.renderTable(30) }); /**/ call_DataFrame(function() { DataFrame.renderTable(31) }); @@ -1253,14 +1236,6 @@ call_DataFrame(function() { DataFrame.renderTable(32) }); -/**/ - -call_DataFrame(function() { DataFrame.renderTable(33) }); - /**/ - -call_DataFrame(function() { DataFrame.renderTable(34) }); - -/**/ -call_DataFrame(function() { DataFrame.renderTable(35) }); +call_DataFrame(function() { DataFrame.renderTable(33) }); /**/ -call_DataFrame(function() { DataFrame.renderTable(36) }); +call_DataFrame(function() { DataFrame.renderTable(34) }); /**/ -call_DataFrame(function() { DataFrame.renderTable(37) }); +call_DataFrame(function() { DataFrame.renderTable(35) }); diff --git a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.addDataFrames.html b/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.addDataFrames.html index 8e3159e5c2..ded64d4c84 100644 --- a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.addDataFrames.html +++ b/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.addDataFrames.html @@ -210,7 +210,7 @@

- df.add(df1, df2) + df.addAll(df1, df2)
Input DataFrame: rowsCount = 7, columnsCount = 5
diff --git a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.addExisting.html b/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.addExisting.html index bd87f6de96..2ca7379d8b 100644 --- a/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.addExisting.html +++ b/docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.addExisting.html @@ -178,7 +178,7 @@
- df.add(score) + df.addAll(score)
Input DataFrame: rowsCount = 7, columnsCount = 5
diff --git a/docs/StardustDocs/topics/ColumnSelectors.md b/docs/StardustDocs/topics/ColumnSelectors.md index 75f91fccb1..facb626c3a 100644 --- a/docs/StardustDocs/topics/ColumnSelectors.md +++ b/docs/StardustDocs/topics/ColumnSelectors.md @@ -544,11 +544,6 @@ df.select { colGroup("name").lastCol { it.name().endsWith("Name") } } -// find the single column inside a column group satisfying the condition -df.select { - Person::name.singleCol { it.name().startsWith("first") } -} - // traversal of columns at any depth from here excluding ColumnGroups df.select { colsAtAnyDepth().filter { !it.isColumnGroup() } } @@ -556,7 +551,7 @@ df.select { colsAtAnyDepth().filter { !it.isColumnGroup() } } df.select { colsAtAnyDepth() } // traversal of columns at any depth with condition -df.select { colsAtAnyDepth().filter() { it.name().contains(":") } } +df.select { colsAtAnyDepth().filter { it.name().contains(":") } } // traversal of columns at any depth to find columns of given type df.select { colsAtAnyDepth().colsOf() } diff --git a/docs/StardustDocs/topics/add.md b/docs/StardustDocs/topics/add.md index fcf6e2a883..988138c81b 100644 --- a/docs/StardustDocs/topics/add.md +++ b/docs/StardustDocs/topics/add.md @@ -79,8 +79,8 @@ columnMapping = column into columnName ```kotlin df.add { - "year of birth" from 2021 - age - age gt 18 into "is adult" + "year of birth" from { 2021 - age } + expr { age > 18 } into "is adult" "details" { name.lastName.map { it.length } into "last name length" "full name" from { name.firstName + " " + name.lastName } @@ -93,8 +93,8 @@ df.add { ```kotlin df.add { - "year of birth" from 2021 - "age"() - "age"() gt 18 into "is adult" + "year of birth" from { 2021 - "age"() } + expr { "age"() > 18 } into "is adult" "details" { "name"["lastName"]().map { it.length } into "last name length" "full name" from { "name"["firstName"]() + " " + "name"["lastName"]() } @@ -130,7 +130,7 @@ Use the following approach to add multiple columns by calling the given API only val personWithCityInfo = df.add { val cityInfo = city.map { queryCityInfo(it) } "cityInfo" { - cityInfo.map { it.location } into CityInfo::location + cityInfo.map { it.location } into "location" cityInfo.map { it.population } into "population" } } @@ -143,7 +143,7 @@ val personWithCityInfo = df.add { val personWithCityInfo = df.add { val cityInfo = "city"().map { queryCityInfo(it) } "cityInfo" { - cityInfo.map { it.location } into CityInfo::location + cityInfo.map { it.location } into "location" cityInfo.map { it.population } into "population" } } @@ -159,7 +159,7 @@ val personWithCityInfo = df.add { ```kotlin val score by columnOf(4, 3, 5, 2, 1, 3, 5) -df.add(score) +df.addAll(score) df + score ``` @@ -171,7 +171,7 @@ df + score ```kotlin -df.add(df1, df2) +df.addAll(df1, df2) ``` diff --git a/docs/StardustDocs/topics/addDf.md b/docs/StardustDocs/topics/addDf.md index 744803be6d..bb0672fa2a 100644 --- a/docs/StardustDocs/topics/addDf.md +++ b/docs/StardustDocs/topics/addDf.md @@ -7,7 +7,7 @@ Returns [`DataFrame`](DataFrame.md) with union of columns from several given [`D ```kotlin -df.add(df1, df2) +df.addAll(df1, df2) ``` diff --git a/docs/StardustDocs/topics/map.md b/docs/StardustDocs/topics/map.md index 7490eb3fc2..51ab28a81c 100644 --- a/docs/StardustDocs/topics/map.md +++ b/docs/StardustDocs/topics/map.md @@ -69,8 +69,8 @@ columnMapping = column into columnName | columnName from column | columnName fro ```kotlin df.mapToFrame { - "year of birth" from 2021 - age - age gt 18 into "is adult" + "year of birth" from { 2021 - age } + expr { age > 18 } into "is adult" name.lastName.map { it.length } into "last name length" "full name" from { name.firstName + " " + name.lastName } +city @@ -82,8 +82,8 @@ df.mapToFrame { ```kotlin df.mapToFrame { - "year of birth" from 2021 - "age"() - "age"() gt 18 into "is adult" + "year of birth" from { 2021 - "age"() } + expr { "age"() > 18 } into "is adult" "name"["lastName"]().map { it.length } into "last name length" "full name" from { "name"["firstName"]() + " " + "name"["lastName"]() } +"city"