Skip to content

Commit cf48803

Browse files
committed
Add kdoc for Split.match and test for Split.inplace
1 parent e90d3c4 commit cf48803

File tree

2 files changed

+16
-0
lines changed
  • core/src
    • main/kotlin/org/jetbrains/kotlinx/dataframe/api
    • test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person

2 files changed

+16
-0
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/split.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,18 @@ internal inline fun <T, C, R> Split<T, C>.by(
126126

127127
// region match
128128

129+
/**
130+
* Creates new String columns according to MatchResult [capturing groups](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-match-result/group-values.html)
131+
* Created columns will be nullable if [regex] doesn't match some rows or there are nulls in original column
132+
* Check [Split.by] overload with regex parameter if you're looking to split String value by [Regex] delimiter
133+
*/
129134
public fun <T, C : String?> Split<T, C>.match(
130135
@Language("RegExp") regex: String,
131136
): SplitWithTransform<T, C, String?> = match(regex.toRegex())
132137

138+
/**
139+
* @include [match]
140+
*/
133141
public fun <T, C : String?> Split<T, C>.match(regex: Regex): SplitWithTransform<T, C, String?> =
134142
by {
135143
it?.let {

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTests.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,6 +2184,14 @@ class DataFrameTests : BaseTest() {
21842184
split["name"] shouldBe typed.name.map { it.toCharArray().toList() }
21852185
}
21862186

2187+
@Test
2188+
fun `split iterable inplace`() {
2189+
val df = dataFrameOf("a" to listOf(listOf(1), null)).split { "a"<List<Int>?>() }.inplace()
2190+
2191+
df["a"].type() shouldBe typeOf<List<Int>>()
2192+
df["a"].values() shouldBe listOf(listOf(1), emptyList())
2193+
}
2194+
21872195
@Test
21882196
fun `split into rows with transform`() {
21892197
val split = typed.split { city }.by { it.toCharArray().toList() }.intoRows()

0 commit comments

Comments
 (0)