diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt index 31a6093ce0..0c3b9d6893 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt @@ -28,6 +28,11 @@ public inline fun Iterable.toDataFrame(): DataFrame = properties() } +public fun Iterable<*>.toDataFrame(klass: KClass<*>): DataFrame<*> = + createDataFrameImpl(klass) { + properties() + } + @Refine @Interpretable("toDataFrameDsl") public inline fun Iterable.toDataFrame(noinline body: CreateDataFrameDsl.() -> Unit): DataFrame = diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt index 2f159e6fcc..f6feba2425 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt @@ -452,4 +452,14 @@ class CreateDataFrameTests { df.participants[0].city } } + + @Test + fun `convert type erased list to dataframe`() { + val data = listOf(Person("Alice", "Cooper", 15, "London")) + val erased: List = data + val df = erased[0]?.let { + erased.toDataFrame(it::class) + } + df shouldBe data.toDataFrame() + } }