Skip to content

Conversation

koperagen
Copy link
Collaborator

@koperagen koperagen commented Mar 7, 2024

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 koperagen added the enhancement New feature or request label Mar 7, 2024
@koperagen koperagen self-assigned this Mar 7, 2024
@Jolanrensen
Copy link
Collaborator

Jolanrensen commented Mar 7, 2024

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 Jolanrensen added this to the 0.14.0 milestone Mar 7, 2024
@koperagen
Copy link
Collaborator Author

image

@koperagen koperagen merged commit ff139d7 into master Apr 2, 2024
@Jolanrensen Jolanrensen deleted the pivot-then branch April 3, 2024 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants