Skip to content

Commit 2ad1b89

Browse files
adding test
1 parent 50796d5 commit 2ad1b89

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public fun <T> Iterable<DataRow<T>>.toDataFrame(): DataFrame<T> {
7272
}
7373
}
7474

75-
@JvmName("toDataFrameMapStringAny?")
75+
@JvmName("toDataFrameMapStringAnyNullable")
7676
public fun Iterable<Map<String, *>>.toDataFrame(): DataFrame<*> = map { it.toDataRow() }.toDataFrame()
7777

7878
@JvmName("toDataFrameAnyColumn")

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,22 @@ class CreateDataFrameTests {
425425
df["value"].toList() shouldBe maps
426426
}
427427

428+
@Test
429+
fun `should convert iterables of maps representing rows to DataFrame with value column`() {
430+
val maps: Iterable<Map<String, *>> = listOf(mapOf("a" to 1, "b" to true), mapOf("c" to 2, "d" to false))
431+
val df = maps.toDataFrame()
432+
df["a"][0] shouldBe 1
433+
df["b"][0] shouldBe true
434+
df["a"][1] shouldBe null
435+
df["b"][1] shouldBe null
436+
df["c"][0] shouldBe null
437+
df["d"][0] shouldBe null
438+
df["c"][1] shouldBe 2
439+
df["d"][1] shouldBe false
440+
df.columnsCount() shouldBe 4
441+
df.rowsCount() shouldBe 2
442+
}
443+
428444
class NoPublicPropsClass(private val a: Int, private val b: String)
429445

430446
@Test

0 commit comments

Comments
 (0)