Skip to content

Commit

Permalink
Merge pull request #756 from Kotlin/value-counts-test
Browse files Browse the repository at this point in the history
Add a test for valueCounts
  • Loading branch information
koperagen authored Jun 27, 2024
2 parents 3e3b5ec + f86c47c commit d401c04
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 d401c04

Please sign in to comment.