Skip to content

Commit

Permalink
Add a test for valueCounts
Browse files Browse the repository at this point in the history
  • Loading branch information
koperagen committed Jun 27, 2024
1 parent 38a376c commit f86c47c
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.jetbrains.kotlinx.dataframe.testSets.person

import io.kotest.matchers.shouldBe
import org.jetbrains.kotlinx.dataframe.api.columnOf
import org.jetbrains.kotlinx.dataframe.api.count
import org.jetbrains.kotlinx.dataframe.api.sort
import org.jetbrains.kotlinx.dataframe.api.sortBy
import org.jetbrains.kotlinx.dataframe.api.sortByDesc
import org.jetbrains.kotlinx.dataframe.api.sortDesc
import org.jetbrains.kotlinx.dataframe.api.valueCounts
import org.junit.Test

class DataColumnTests : BaseTest() {
Expand All @@ -14,4 +17,12 @@ class DataColumnTests : BaseTest() {
typed.age.sort() shouldBe typed.sortBy { age }.age
typed.age.sortDesc() shouldBe typed.sortByDesc { age }.age
}

@Test
fun `value counts`() {
val languages by columnOf("Kotlin", "Kotlin", null, null, "C++")
val languageCounts = languages.valueCounts()
languageCounts[languages].values() shouldBe listOf("Kotlin", "C++")
languageCounts.count shouldBe listOf(2, 1)
}
}

0 comments on commit f86c47c

Please sign in to comment.