Skip to content

Commit 6e9f176

Browse files
committed
Update examples for multi-column add and map
1 parent 173881e commit 6e9f176

File tree

3 files changed

+20
-20
lines changed
  • core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api
  • docs/StardustDocs/topics

3 files changed

+20
-20
lines changed

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Modify.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,8 @@ class Modify : TestBase() {
919919
fun addMany_properties() {
920920
// SampleStart
921921
df.add {
922-
"year of birth" from 2021 - age
923-
age gt 18 into "is adult"
922+
"year of birth" from { 2021 - age }
923+
expr { age > 18 } into "is adult"
924924
"details" {
925925
name.lastName.map { it.length } into "last name length"
926926
"full name" from { name.firstName + " " + name.lastName }
@@ -934,8 +934,8 @@ class Modify : TestBase() {
934934
fun addMany_strings() {
935935
// SampleStart
936936
df.add {
937-
"year of birth" from 2021 - "age"<Int>()
938-
"age"<Int>() gt 18 into "is adult"
937+
"year of birth" from { 2021 - "age"<Int>() }
938+
expr { "age"<Int>() > 18 } into "is adult"
939939
"details" {
940940
"name"["lastName"]<String>().map { it.length } into "last name length"
941941
"full name" from { "name"["firstName"]<String>() + " " + "name"["lastName"]<String>() }
@@ -989,8 +989,8 @@ class Modify : TestBase() {
989989
fun mapMany_properties() {
990990
// SampleStart
991991
df.mapToFrame {
992-
"year of birth" from 2021 - age
993-
age gt 18 into "is adult"
992+
"year of birth" from { 2021 - age }
993+
expr { age > 18 } into "is adult"
994994
name.lastName.map { it.length } into "last name length"
995995
"full name" from { name.firstName + " " + name.lastName }
996996
+city
@@ -1003,8 +1003,8 @@ class Modify : TestBase() {
10031003
fun mapMany_strings() {
10041004
// SampleStart
10051005
df.mapToFrame {
1006-
"year of birth" from 2021 - "age"<Int>()
1007-
"age"<Int>() gt 18 into "is adult"
1006+
"year of birth" from { 2021 - "age"<Int>() }
1007+
expr { "age"<Int>() > 18 } into "is adult"
10081008
"name"["lastName"]<String>().map { it.length } into "last name length"
10091009
"full name" from { "name"["firstName"]<String>() + " " + "name"["lastName"]<String>() }
10101010
+"city"

docs/StardustDocs/topics/add.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ columnMapping = column into columnName
7979

8080
```kotlin
8181
df.add {
82-
"year of birth" from 2021 - age
83-
age gt 18 into "is adult"
82+
"year of birth" from { 2021 - age }
83+
expr { age > 18 } into "is adult"
8484
"details" {
8585
name.lastName.map { it.length } into "last name length"
8686
"full name" from { name.firstName + " " + name.lastName }
@@ -93,8 +93,8 @@ df.add {
9393

9494
```kotlin
9595
df.add {
96-
"year of birth" from 2021 - "age"<Int>()
97-
"age"<Int>() gt 18 into "is adult"
96+
"year of birth" from { 2021 - "age"<Int>() }
97+
expr { "age"<Int>() > 18 } into "is adult"
9898
"details" {
9999
"name"["lastName"]<String>().map { it.length } into "last name length"
100100
"full name" from { "name"["firstName"]<String>() + " " + "name"["lastName"]<String>() }
@@ -130,7 +130,7 @@ Use the following approach to add multiple columns by calling the given API only
130130
val personWithCityInfo = df.add {
131131
val cityInfo = city.map { queryCityInfo(it) }
132132
"cityInfo" {
133-
cityInfo.map { it.location } into CityInfo::location
133+
cityInfo.map { it.location } into "location"
134134
cityInfo.map { it.population } into "population"
135135
}
136136
}
@@ -143,7 +143,7 @@ val personWithCityInfo = df.add {
143143
val personWithCityInfo = df.add {
144144
val cityInfo = "city"<String?>().map { queryCityInfo(it) }
145145
"cityInfo" {
146-
cityInfo.map { it.location } into CityInfo::location
146+
cityInfo.map { it.location } into "location"
147147
cityInfo.map { it.population } into "population"
148148
}
149149
}
@@ -159,7 +159,7 @@ val personWithCityInfo = df.add {
159159
```kotlin
160160
val score by columnOf(4, 3, 5, 2, 1, 3, 5)
161161

162-
df.add(score)
162+
df.addAll(score)
163163
df + score
164164
```
165165

@@ -171,7 +171,7 @@ df + score
171171
<!---FUN addDataFrames-->
172172

173173
```kotlin
174-
df.add(df1, df2)
174+
df.addAll(df1, df2)
175175
```
176176

177177
<inline-frame src="resources/org.jetbrains.kotlinx.dataframe.samples.api.Modify.addDataFrames.html" width="100%"/>

docs/StardustDocs/topics/map.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ columnMapping = column into columnName | columnName from column | columnName fro
6969

7070
```kotlin
7171
df.mapToFrame {
72-
"year of birth" from 2021 - age
73-
age gt 18 into "is adult"
72+
"year of birth" from { 2021 - age }
73+
expr { age > 18 } into "is adult"
7474
name.lastName.map { it.length } into "last name length"
7575
"full name" from { name.firstName + " " + name.lastName }
7676
+city
@@ -82,8 +82,8 @@ df.mapToFrame {
8282

8383
```kotlin
8484
df.mapToFrame {
85-
"year of birth" from 2021 - "age"<Int>()
86-
"age"<Int>() gt 18 into "is adult"
85+
"year of birth" from { 2021 - "age"<Int>() }
86+
expr { "age"<Int>() > 18 } into "is adult"
8787
"name"["lastName"]<String>().map { it.length } into "last name length"
8888
"full name" from { "name"["firstName"]<String>() + " " + "name"["lastName"]<String>() }
8989
+"city"

0 commit comments

Comments
 (0)