Skip to content

Commit 8dfbf1c

Browse files
authored
Merge pull request #758 from Kotlin/value-counts-test
Add a test for valueCounts
2 parents a71afa9 + c199c0e commit 8dfbf1c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataColumnTests.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package org.jetbrains.kotlinx.dataframe.testSets.person
22

33
import io.kotest.matchers.shouldBe
4+
import org.jetbrains.kotlinx.dataframe.api.columnOf
5+
import org.jetbrains.kotlinx.dataframe.api.count
46
import org.jetbrains.kotlinx.dataframe.api.sort
57
import org.jetbrains.kotlinx.dataframe.api.sortBy
68
import org.jetbrains.kotlinx.dataframe.api.sortByDesc
79
import org.jetbrains.kotlinx.dataframe.api.sortDesc
10+
import org.jetbrains.kotlinx.dataframe.api.valueCounts
811
import org.junit.Test
912

1013
class DataColumnTests : BaseTest() {
@@ -14,4 +17,12 @@ class DataColumnTests : BaseTest() {
1417
typed.age.sort() shouldBe typed.sortBy { age }.age
1518
typed.age.sortDesc() shouldBe typed.sortByDesc { age }.age
1619
}
20+
21+
@Test
22+
fun `value counts`() {
23+
val languages by columnOf("Kotlin", "Kotlin", null, null, "C++")
24+
val languageCounts = languages.valueCounts()
25+
languageCounts[languages].values() shouldBe listOf("Kotlin", "C++")
26+
languageCounts.count.values() shouldBe listOf(2, 1)
27+
}
1728
}

0 commit comments

Comments
 (0)