File tree Expand file tree Collapse file tree 4 files changed +44
-2
lines changed
main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api
test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person
main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api
test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person Expand file tree Collapse file tree 4 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ internal fun describeImpl(cols: List<AnyCol>): DataFrame<ColumnDescription> {
6464 if (hasLongPaths) {
6565 ColumnDescription ::path from { it.path() }
6666 }
67- ColumnDescription ::type from { it.type.jvmErasure.simpleName }
67+ ColumnDescription ::type from { buildTypeName(it) }
6868 ColumnDescription ::count from { it.size }
6969 ColumnDescription ::unique from { it.countDistinct() }
7070 ColumnDescription ::nulls from { it.values.count { it == null } }
@@ -91,3 +91,12 @@ internal fun describeImpl(cols: List<AnyCol>): DataFrame<ColumnDescription> {
9191
9292 return df.cast()
9393}
94+
95+ private fun buildTypeName (it : AnyCol ): String {
96+ val rawJavaType = it.type.jvmErasure.simpleName.toString()
97+ return if (it.type.isMarkedNullable) {
98+ " $rawJavaType ?"
99+ } else {
100+ rawJavaType
101+ }
102+ }
Original file line number Diff line number Diff line change @@ -2170,6 +2170,18 @@ class DataFrameTests : BaseTest() {
21702170 fun describe () {
21712171 val desc = typed.group { age and weight }.into(" info" ).groupBy { city }.toDataFrame().describe()
21722172 desc.nrow shouldBe typed.ncol + 1
2173+ desc[" type" ][0 ] shouldBe " String?"
2174+ desc[" path" ][1 ] shouldBe listOf (" group" , " name" )
2175+ desc[" name" ][0 ] shouldBe " city"
2176+ desc[" count" ][3 ] shouldBe 7
2177+ desc[" unique" ][4 ] shouldBe 6
2178+ desc[" nulls" ][3 ] shouldBe 2
2179+ desc[" top" ][0 ] shouldBe " London"
2180+ desc[" mean" ][2 ] shouldBe 28.571428571428573
2181+ desc[" std" ][2 ] shouldBe 11.073348527841414
2182+ desc[" min" ][2 ] shouldBe 15
2183+ desc[" median" ][2 ] shouldBe 30
2184+ desc[" max" ][2 ] shouldBe 45
21732185 desc.print ()
21742186 }
21752187
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ internal fun describeImpl(cols: List<AnyCol>): DataFrame<ColumnDescription> {
6464 if (hasLongPaths) {
6565 ColumnDescription ::path from { it.path() }
6666 }
67- ColumnDescription ::type from { it.type.jvmErasure.simpleName }
67+ ColumnDescription ::type from { buildTypeName(it) }
6868 ColumnDescription ::count from { it.size }
6969 ColumnDescription ::unique from { it.countDistinct() }
7070 ColumnDescription ::nulls from { it.values.count { it == null } }
@@ -91,3 +91,12 @@ internal fun describeImpl(cols: List<AnyCol>): DataFrame<ColumnDescription> {
9191
9292 return df.cast()
9393}
94+
95+ private fun buildTypeName (it : AnyCol ): String {
96+ val rawJavaType = it.type.jvmErasure.simpleName.toString()
97+ return if (it.type.isMarkedNullable) {
98+ " $rawJavaType ?"
99+ } else {
100+ rawJavaType
101+ }
102+ }
Original file line number Diff line number Diff line change @@ -2170,6 +2170,18 @@ class DataFrameTests : BaseTest() {
21702170 fun describe () {
21712171 val desc = typed.group { age and weight }.into(" info" ).groupBy { city }.toDataFrame().describe()
21722172 desc.nrow shouldBe typed.ncol + 1
2173+ desc[" type" ][0 ] shouldBe " String?"
2174+ desc[" path" ][1 ] shouldBe listOf (" group" , " name" )
2175+ desc[" name" ][0 ] shouldBe " city"
2176+ desc[" count" ][3 ] shouldBe 7
2177+ desc[" unique" ][4 ] shouldBe 6
2178+ desc[" nulls" ][3 ] shouldBe 2
2179+ desc[" top" ][0 ] shouldBe " London"
2180+ desc[" mean" ][2 ] shouldBe 28.571428571428573
2181+ desc[" std" ][2 ] shouldBe 11.073348527841414
2182+ desc[" min" ][2 ] shouldBe 15
2183+ desc[" median" ][2 ] shouldBe 30
2184+ desc[" max" ][2 ] shouldBe 45
21732185 desc.print ()
21742186 }
21752187
You can’t perform that action at this time.
0 commit comments