Kotlin / dataframe

Structured data processing in Kotlin
https://kotlin.github.io/dataframe/overview.html
Apache License 2.0
768 stars 48 forks source link

then operation in pivot column selection DSL inside aggregate #617

Closed koperagen closed 3 months ago

koperagen commented 4 months ago

Can be considered a feature, because pivoting inside groupBy aggregate is a bit more powerful. So then support unlocks some use cases

Additional aggregation per each group

val df = dataFrameOf(
    "category1" to List(12) { it % 3 },
    "category2" to List(12) { "category2_${it % 2}" },
    "category3" to List(12) { "category3_${it % 5}" },
    "value" to List(12) { it }
)

val df1 = df.groupBy("category1").aggregate {
    count() into "totalCount" // 
    pivot { "category2" then "category3" }.count() into "counts"
}

While this syntax wouldn't allow additional aggregation per each group

df.pivot { "category2" then "category3" }.groupBy("category1").count()
Jolanrensen commented 4 months ago

Could you share some examples of what this will do? (df.toStaticHtml() can be rendered on GH :) )

Edit: Ah, so basically, you change the receiver so that PivotDsl calls can also be by pivot in GroupyBy.aggregate {}, sounds useful :)

koperagen commented 3 months ago

image