-
Notifications
You must be signed in to change notification settings - Fork 15
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
Sort doesn't work after agg without ungroup #41
Comments
Since it is a grouping I expect the sort to occur within each group. For the example above, there is only one data per group, so sorting is pretty much unnecessary, hence the unsorted look. |
@samukweku Maybe I didn't fully understand the difference. Can you give me an example of within group sorting? |
Try grouping by the
the function you used is a reducing function - you get just one value per group... no point sorting within a group with a single value. Hope the code above explains better sorting within a group |
@samarpan-rai yeah I might argue this is expected behaviour. Just to check, have you seen this guide on the docs? The @samukweku just mentioning it as a by the way, but on GitHub you can get pretty syntax highlighting for python if you add this at the start of a code snippet.
|
|
@samarpan-rai just to check, can I close this issue? |
Yes, thank you! It indeed makes sense for within group sorting.
I did read it shortly but seem to have missed "With groups active, still perform the sorting but only within each group." I tried to transfer my experience from R's df %>%
group_by(name) %>%
count(name) %>%
arrange(n) |
Yes |
I am not sure if this is a bug but it is definitely not a feature request so I am writing it as a bug report.
Problem
I was expecting the following code to return a sorted list of the count grouped by the
primary_type
key but that is not the case. I see an unsorted list. Is this an expected behaviour?Additional context
Adding
ungroup
afteragg
and beforesort
solves it. The following code produces what I want.The text was updated successfully, but these errors were encountered: