Skip to content

Commit d9b90e7

Browse files
authored
Merge pull request #653 from Kotlin/split-docs-fixes
Updated split documentation
2 parents f247331 + e1bfdc5 commit d9b90e7

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

docs/StardustDocs/topics/split.md

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
<!---IMPORT org.jetbrains.kotlinx.dataframe.samples.api.Modify-->
44

5-
Splits every value in the given columns into several values and optionally spreads them horizontally or vertically.
5+
This operation splits every value in the given columns into several values,
6+
and optionally spreads them horizontally or vertically.
67

78
```text
89
df.split { columns }
910
[.cast<Type>()]
10-
[.by(delimeters) | .by { splitter } | .match(regex)] // how to split cell value
11+
[.by(delimiters|regex [,trim=true][,ignoreCase=true][,limit=0]) | .by { splitter } | .match(regex)] // how to split cell value
1112
[.default(value)] // how to fill nulls
1213
.into(columnNames) [ { columnNamesGenerator } ] | .inward(columnNames) [ { columnNamesGenerator } | .inplace() | .intoRows() | .intoColumns() ] // where to store results
1314
@@ -19,11 +20,11 @@ The following types of columns can be split without any _splitter_ configuration
1920
* `List`: split into elements
2021
* [`DataFrame`](DataFrame.md): split into rows
2122

22-
## Split inplace
23+
## Split in place
2324

24-
Stores split values as lists in original columns.
25+
Stores split values as lists in their original columns.
2526

26-
Use `.inplace()` terminal operation in `split` configuration to spread split values inplace:
27+
Use the `.inplace()` terminal operation in your `split` configuration to spread split values in place:
2728

2829
<!---FUN splitInplace-->
2930
<tabs>
@@ -57,15 +58,18 @@ df.split { "name"["firstName"]<String>() }.by { it.asIterable() }.inplace()
5758
## Split horizontally
5859

5960
Stores split values in new columns.
60-
* `into(col1, col2, ... )`store split values in new top-level columns
61-
* `inward(col1, col2, ...)`store split values in new columns nested inside original column
62-
* `intoColumns`split [`FrameColumn`](DataColumn.md#framecolumn) into [`ColumnGroup`](DataColumn.md#columngroup) storing in every cell a `List` of original values per every column
61+
* `into(col1, col2, ... )`stores split values in new top-level columns
62+
* `inward(col1, col2, ...)`stores split values in new columns nested inside the original column
63+
* `intoColumns`splits [`FrameColumns`](DataColumn.md#framecolumn) into [`ColumnGroups`](DataColumn.md#columngroup) storing in every cell in a `List` of the original values per column
6364

6465
**Reverse operation:** [`merge`](merge.md)
6566

66-
`columnNamesGenerator` is used to generate names for additional columns when the list of explicitly specified `columnNames` was not long enough. `columnIndex` starts with `1` for the first additional column name.
67+
`columnNamesGenerator` is used to generate names for additional columns when the list of explicitly specified `columnNames` is not long enough.
68+
`columnIndex` starts with `1` for the first additional column name.
6769

68-
Default `columnNamesGenerator` generates column names `split1`, `split2`...
70+
The default `columnNamesGenerator` generates column names like `split1`, `split2`, etc.
71+
72+
Some examples:
6973

7074
<!---FUN split-->
7175
<tabs>
@@ -131,18 +135,7 @@ df.split { "name"["lastName"]<String>() }
131135
<dataFrame src="org.jetbrains.kotlinx.dataframe.samples.api.Modify.split1.html"/>
132136
<!---END-->
133137

134-
`String` columns can also be split into group matches of [`Regex`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-regex/) pattern:
135-
136-
<!---FUN splitRegex-->
137-
138-
```kotlin
139-
val merged = df.merge { name.lastName and name.firstName }
140-
.by { it[0] + " (" + it[1] + ")" }
141-
.into("name")
142-
```
143-
144-
<dataFrame src="org.jetbrains.kotlinx.dataframe.samples.api.Modify.splitRegex.html"/>
145-
<!---END-->
138+
`String` columns can also be split into group matches of [`Regex`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-regex/) patterns:
146139

147140
<!---FUN splitRegex1-->
148141

@@ -182,11 +175,11 @@ df.split { group }.intoColumns()
182175

183176
## Split vertically
184177

185-
Stores split values in new rows duplicating values in other columns.
178+
Stores split values in new rows, duplicating values in other columns.
186179

187180
**Reverse operation:** [`implode`](implode.md)
188181

189-
Use `.intoRows()` terminal operation in `split` configuration to spread split values vertically:
182+
Use the `.intoRows()` terminal operation in your `split` configuration to spread split values vertically:
190183

191184
<!---FUN splitIntoRows-->
192185
<tabs>

0 commit comments

Comments
 (0)