dataframe icon indicating copy to clipboard operation
dataframe copied to clipboard

then operation in pivot column selection DSL inside aggregate

Open koperagen opened this issue 11 months ago • 2 comments

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()

koperagen avatar Mar 07 '24 19:03 koperagen

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 :)

Jolanrensen avatar Mar 07 '24 19:03 Jolanrensen

image

koperagen avatar Mar 08 '24 10:03 koperagen