|
4 | 4 |
|
5 | 5 | Returns `DataFrame` which contains all columns from original `DataFrame` followed by newly added columns. Original `DataFrame` is not modified.
|
6 | 6 |
|
7 |
| -**Create new column and add it to `DataFrame`:** |
| 7 | +## Create new column and add it to `DataFrame` |
8 | 8 |
|
9 | 9 | ```text
|
10 | 10 | add(columnName: String) { rowExpression }
|
@@ -55,7 +55,7 @@ df.add("fibonacci") {
|
55 | 55 |
|
56 | 56 | <!---END-->
|
57 | 57 |
|
58 |
| -**Create and add several columns to `DataFrame`:** |
| 58 | +## Create and add several columns to `DataFrame` |
59 | 59 |
|
60 | 60 | ```kotlin
|
61 | 61 | add {
|
@@ -130,41 +130,41 @@ df.add {
|
130 | 130 | </tab></tabs>
|
131 | 131 | <!---END-->
|
132 | 132 |
|
133 |
| -**Add existing column to `DataFrame`:** |
| 133 | +### Create columns using intermediate result |
134 | 134 |
|
135 |
| -<!---FUN addExisting--> |
| 135 | +<!---FUN addCalculated--> |
136 | 136 |
|
137 | 137 | ```kotlin
|
138 |
| -val score by columnOf(4, 3, 5, 2, 1, 3, 5) |
139 |
| - |
140 |
| -df.add(score) |
141 |
| -df + score |
| 138 | +val personWithCityInfo = df.add { |
| 139 | + val cityInfo = city.map { queryCityInfo(it) } |
| 140 | + "cityInfo" { |
| 141 | + cityInfo.map { it.location } into CityInfo::location |
| 142 | + cityInfo.map { it.population } into "population" |
| 143 | + } |
| 144 | +} |
142 | 145 | ```
|
143 | 146 |
|
144 | 147 | <!---END-->
|
145 | 148 |
|
146 |
| -**Add all columns from another `DataFrame`:** |
| 149 | +## Add existing column to `DataFrame` |
147 | 150 |
|
148 |
| -<!---FUN addDfs--> |
| 151 | +<!---FUN addExisting--> |
149 | 152 |
|
150 | 153 | ```kotlin
|
151 |
| -df.add(df1, df2) |
| 154 | +val score by columnOf(4, 3, 5, 2, 1, 3, 5) |
| 155 | + |
| 156 | +df.add(score) |
| 157 | +df + score |
152 | 158 | ```
|
153 | 159 |
|
154 | 160 | <!---END-->
|
155 | 161 |
|
156 |
| -**Add columns using intermediate result:** |
| 162 | +## Add all columns from another `DataFrame` |
157 | 163 |
|
158 |
| -<!---FUN addCalculated--> |
| 164 | +<!---FUN addDfs--> |
159 | 165 |
|
160 | 166 | ```kotlin
|
161 |
| -val personWithCityInfo = df.add { |
162 |
| - val cityInfo = city.map { queryCityInfo(it) } |
163 |
| - "cityInfo" { |
164 |
| - cityInfo.map { it.location } into CityInfo::location |
165 |
| - cityInfo.map { it.population } into "population" |
166 |
| - } |
167 |
| -} |
| 167 | +df.add(df1, df2) |
168 | 168 | ```
|
169 | 169 |
|
170 | 170 | <!---END-->
|
|
0 commit comments