diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/describe.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/describe.kt index 74b0567b2a..93246f5ca2 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/describe.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/describe.kt @@ -64,7 +64,7 @@ internal fun describeImpl(cols: List): DataFrame { if (hasLongPaths) { ColumnDescription::path from { it.path() } } - ColumnDescription::type from { it.type.jvmErasure.simpleName } + ColumnDescription::type from { buildTypeName(it) } ColumnDescription::count from { it.size } ColumnDescription::unique from { it.countDistinct() } ColumnDescription::nulls from { it.values.count { it == null } } @@ -91,3 +91,12 @@ internal fun describeImpl(cols: List): DataFrame { return df.cast() } + +private fun buildTypeName(it: AnyCol): String { + val rawJavaType = it.type.jvmErasure.simpleName.toString() + return if (it.type.isMarkedNullable) { + "$rawJavaType?" + } else { + rawJavaType + } +} diff --git a/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTests.kt b/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTests.kt index 4bd50bad7b..4c9d0cc5b7 100644 --- a/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTests.kt +++ b/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTests.kt @@ -2170,6 +2170,18 @@ class DataFrameTests : BaseTest() { fun describe() { val desc = typed.group { age and weight }.into("info").groupBy { city }.toDataFrame().describe() desc.nrow shouldBe typed.ncol + 1 + desc["type"][0] shouldBe "String?" + desc["path"][1] shouldBe listOf("group", "name") + desc["name"][0] shouldBe "city" + desc["count"][3] shouldBe 7 + desc["unique"][4] shouldBe 6 + desc["nulls"][3] shouldBe 2 + desc["top"][0] shouldBe "London" + desc["mean"][2] shouldBe 28.571428571428573 + desc["std"][2] shouldBe 11.073348527841414 + desc["min"][2] shouldBe 15 + desc["median"][2] shouldBe 30 + desc["max"][2] shouldBe 45 desc.print() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/describe.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/describe.kt index 74b0567b2a..93246f5ca2 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/describe.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/describe.kt @@ -64,7 +64,7 @@ internal fun describeImpl(cols: List): DataFrame { if (hasLongPaths) { ColumnDescription::path from { it.path() } } - ColumnDescription::type from { it.type.jvmErasure.simpleName } + ColumnDescription::type from { buildTypeName(it) } ColumnDescription::count from { it.size } ColumnDescription::unique from { it.countDistinct() } ColumnDescription::nulls from { it.values.count { it == null } } @@ -91,3 +91,12 @@ internal fun describeImpl(cols: List): DataFrame { return df.cast() } + +private fun buildTypeName(it: AnyCol): String { + val rawJavaType = it.type.jvmErasure.simpleName.toString() + return if (it.type.isMarkedNullable) { + "$rawJavaType?" + } else { + rawJavaType + } +} diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTests.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTests.kt index 4bd50bad7b..4c9d0cc5b7 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTests.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTests.kt @@ -2170,6 +2170,18 @@ class DataFrameTests : BaseTest() { fun describe() { val desc = typed.group { age and weight }.into("info").groupBy { city }.toDataFrame().describe() desc.nrow shouldBe typed.ncol + 1 + desc["type"][0] shouldBe "String?" + desc["path"][1] shouldBe listOf("group", "name") + desc["name"][0] shouldBe "city" + desc["count"][3] shouldBe 7 + desc["unique"][4] shouldBe 6 + desc["nulls"][3] shouldBe 2 + desc["top"][0] shouldBe "London" + desc["mean"][2] shouldBe 28.571428571428573 + desc["std"][2] shouldBe 11.073348527841414 + desc["min"][2] shouldBe 15 + desc["median"][2] shouldBe 30 + desc["max"][2] shouldBe 45 desc.print() }