-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grouped DataFrame with array elements fails to combine #3424
Comments
Another example: julia> combine(groupby(a, :k), :t=>stack)
4×2 DataFrame
Row │ k t_stack
│ Int64 Int64
─────┼────────────────
1 │ 1 1
2 │ 1 2
3 │ 2 3
4 │ 2 4 Expected behavior: julia> combine(groupby(a, :k), :t=>stack)
4×2 DataFrame
Row │ k t_stack
│ Int64 Array…
─────┼────────────────
1 │ 1 [1, 2]
2 │ 2 [3, 4] I'm uncertain about the internal mechanism, but it appears that the DataFrame might undergo |
Alternative using |
This is a design feature. The rule is that if function returns a vector it gets expanded. The reason is that in a vast majority of cases this is what users expect, and requiring them to It is important to understand that aggregation functions decide about how to handle the results on transformations based on the VALUE returned, not based on a function called. Relying on a function called would produce many special cases that would be even harder to learn. Your case is rare (applying
So you can write e.g. one of these (whichever is easier to remember for you):
To get what you want. |
Thank you for your response. I have updated the document to ensure proper dissemination. |
When performing a combine operation on a DataFrame using the
combine
function withgroupby
, the output format is inconsistent based on the type of aggregation being applied. Specifically, when aggregating with the:v=>sum
operation, the expected output should retain the array format for the column being aggregated. However, the current behavior results in a scalar value for the aggregated column.Expected:
The text was updated successfully, but these errors were encountered: