-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
v0.14 group.head() not really grouped #7287
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
Comments
http://pandas.pydata.org/pandas-docs/stable/whatsnew.html#groupby-api-changes The previous output had A as the index (unlike a filter) see #5755 #6533. Filter is another example which doesn't sort by the group keys... IMO they shouldn't be sorted. |
I saw the docs. But the problem (for me) does not appear with head(1), it only starts to be confusing (in terms of expecting a 'grouped' result) with head(n) and n > 1. |
So you clearly want this:
However, I think that it could easily get fooled and so it returns it in index order
You can also do this
Their is a |
filter also doesn't respect sort... surprisingly the default is sort=True, so IMO I don't think it's reasonably for this behaviour to change. |
@hayd ok...let's think about this and see what if anyything should be changed |
I think i finally got to the bottom of this. basically so right now So |
My opinion is that sort should just not be an option for filter-like groupby methods...definitely don't think it should ever be the default. Perhaps I'm missing a compelling argument for this API change... but I thought this was raised in the larger "consistent groupby" issue. Maybe the answer here is to change the docstring of groupby's sort argument to say "for aggregated output" (just like as_index) ? If a user wants this behaviour groupby then sort... ? |
My biggest problem is the mental disconnect with what I expect as an outcome of 'groupby' (but maybe that's where I fail?). The user, at least me, expects that everything after a groupby is |
Closing as a duplicate of #17775 |
This might not necessarily a new thing since 0.14, but I find the output of group.head() not appropriate for a grouping:
My expectation of the previous output would be:
because, after all, this is the result of a grouping, so things should be displayed grouped, shouldn't they?
The text was updated successfully, but these errors were encountered: