From f86c47c130f24ea1dd7e890159766fb136945a98 Mon Sep 17 00:00:00 2001 From: Nikita Klimenko Date: Thu, 27 Jun 2024 14:38:03 +0300 Subject: [PATCH] Add a test for valueCounts --- .../dataframe/testSets/person/DataColumnTests.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataColumnTests.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataColumnTests.kt index 83ae9780c1..c30dfd8afd 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataColumnTests.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataColumnTests.kt @@ -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() { @@ -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) + } }