-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
groupby.nth lost multiindex #11830
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
looks like a bug, but this is a quite complicated area, see here If you'd like to dig-in would be great. |
By the way, I just hit this I think, and you don't need a multi-index to cause it:
gives:
(And I would expect the two to be equal). It seems that for whatever reason nth is having its index lost. |
I just built several versions in the past to see if this was a regression. It's doesn't look like a regression. I've tested as far back as 0.12. |
Sorry. I think my test may have been depending on a feature which didn't exist in older versions (the
The latest version gives a non-zero exit status. Going to try an automated git bisect. Any hints on how to make pandas build faster in development mode? |
http://pandas.pydata.org/pandas-docs/stable/groupby.html#groupby-nth
|
OK. Not that it matters but I was able to bisect the behaviour change to c444c73. FWIW, For me this wasn't very clearly explained in the documentation, for example Here. I guess it comes down to how you read the word "rows". For me, that just meant that it was picking out a row within the group, but I still expected it to have the index for that group - just as first() and last() do. It would be very useful if the docs made this behaviour difference clear. Another thing that is a surprise to me: >>> P.DataFrame({"a": [1, 2, 3, 4], "b": [9, 9, 9, 9]}).groupby("a").b.nth(0)
0 9
1 9
2 9
3 9
Name: b, dtype: int64 Is different from (flipped >>> P.DataFrame({"a": [1, 2, 3, 4], "b": [9, 9, 9, 9]}).groupby("a").nth(0).b
a
1 9
2 9
3 9
4 9
Name: b, dtype: int64 (Edited: I accidentally pressed submit prematurely!) |
the issue is we need a bunch more test as their is s bug in the results - can u do a PR with some more tests - would help move this along |
I believe this was fixed with 445d1c6. The discussion for #11039 mentions that the commit now makes
|
ok #12839 closed this, but see the comment on the actual PR (we ended up re-opening that one) because the state was not being preserved. welcome to have you address that issue. thanks! |
It is bug or not? Because in function
mean
andfirst
it is OK.link
The text was updated successfully, but these errors were encountered: