org.jetbrains.kotlinx.ggdsl.dataframe.context.GroupedDataFrameContext.kt Maven / Gradle / Ivy
package org.jetbrains.kotlinx.ggdsl.dataframe.context
import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.api.GroupBy
import org.jetbrains.kotlinx.dataframe.api.concat
import org.jetbrains.kotlinx.dataframe.api.first
import org.jetbrains.kotlinx.ggdsl.dataframe.data.DataFrameWrapper
import org.jetbrains.kotlinx.ggdsl.dataframe.data.LazyGroupedDataFrame
/**
* Wrapper of [GroupBy] that allows to access grouping keys and dataframe columns.
*
* @property groupKey grouping keys accessor.
* @property column columns accessor.
*/
public class GroupedDataFrameContext(private val groupBy: GroupBy) {
public val groupKey: DataFrame = groupBy.keys
public val column: DataFrame = groupBy.groups.first() // TODO
@PublishedApi
internal fun toLazy(): LazyGroupedDataFrame = LazyGroupedDataFrame(
groupKey.columns().map { it.name() },
DataFrameWrapper(groupBy.groups.concat())
)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy