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> {
64
64
if (hasLongPaths) {
65
65
ColumnDescription ::path from { it.path() }
66
66
}
67
- ColumnDescription ::type from { it.type.jvmErasure.simpleName }
67
+ ColumnDescription ::type from { buildTypeName(it) }
68
68
ColumnDescription ::count from { it.size }
69
69
ColumnDescription ::unique from { it.countDistinct() }
70
70
ColumnDescription ::nulls from { it.values.count { it == null } }
@@ -91,3 +91,12 @@ internal fun describeImpl(cols: List<AnyCol>): DataFrame<ColumnDescription> {
91
91
92
92
return df.cast()
93
93
}
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() {
2170
2170
fun describe () {
2171
2171
val desc = typed.group { age and weight }.into(" info" ).groupBy { city }.toDataFrame().describe()
2172
2172
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
2173
2185
desc.print ()
2174
2186
}
2175
2187
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ internal fun describeImpl(cols: List<AnyCol>): DataFrame<ColumnDescription> {
64
64
if (hasLongPaths) {
65
65
ColumnDescription ::path from { it.path() }
66
66
}
67
- ColumnDescription ::type from { it.type.jvmErasure.simpleName }
67
+ ColumnDescription ::type from { buildTypeName(it) }
68
68
ColumnDescription ::count from { it.size }
69
69
ColumnDescription ::unique from { it.countDistinct() }
70
70
ColumnDescription ::nulls from { it.values.count { it == null } }
@@ -91,3 +91,12 @@ internal fun describeImpl(cols: List<AnyCol>): DataFrame<ColumnDescription> {
91
91
92
92
return df.cast()
93
93
}
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() {
2170
2170
fun describe () {
2171
2171
val desc = typed.group { age and weight }.into(" info" ).groupBy { city }.toDataFrame().describe()
2172
2172
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
2173
2185
desc.print ()
2174
2186
}
2175
2187
You can’t perform that action at this time.
0 commit comments