Skip to content

Commit 9de6462

Browse files
committed
adds breaking pivot test
1 parent 9e372d3 commit 9de6462

File tree

1 file changed

+17
-0
lines changed
  • core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.jetbrains.kotlinx.dataframe.api
22

33
import io.kotest.matchers.shouldBe
4+
import org.jetbrains.kotlinx.dataframe.impl.commonType
45
import org.junit.Test
56
import kotlin.reflect.typeOf
67

@@ -168,4 +169,20 @@ class PivotTests {
168169
}
169170
df1 shouldBe df.pivot { "category2" then "category3" }.groupBy("category1").count()
170171
}
172+
173+
@Test
174+
fun `pivot with default of other type`() {
175+
val df = dataFrameOf("firstName", "lastName", "age", "city", "weight", "isHappy")(
176+
"Alice", "Cooper", 15, "London", 54, true,
177+
"Bob", "Dylan", 45, "Dubai", 87, true,
178+
"Charlie", "Daniels", 20, "Moscow", null, false,
179+
"Charlie", "Chaplin", 40, "Milan", null, true,
180+
"Bob", "Marley", 30, "Tokyo", 68, true,
181+
"Alice", "Wolf", 20, null, 55, false,
182+
"Charlie", "Byrd", 30, "Moscow", 90, true
183+
).group("firstName", "lastName").into("name")
184+
185+
val pivoted = df.pivot("city").groupBy("name").default(0).min()
186+
pivoted["city"]["London"]["isHappy"].type() shouldBe listOf(typeOf<Int>(), typeOf<Boolean>()).commonType()
187+
}
171188
}

0 commit comments

Comments
 (0)