-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: groupby.transform length mismatch under certain specifications #9697
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
Note that
works, so the bug must be in the fastpath. |
More information: the use of We're also seeing things like
which makes me think there's definitely been a confusion about the index. |
yep, this https://github.com/pydata/pandas/blob/master/pandas/core/groupby.py#L2456 |
Switching count -> size seems to fix the original problem. Doesn't pass the tests I made which revealed the index problem above. Shall I submit a PR with the count/size switch here and open a new issue for that one? |
@dsm054 that would be gr8 thxs |
I may be having the same problem in Pandas 0.16.1. I describe it here: I have a Pandas Dataframe with hierarchically indexed columns. Eg:
Giving:
However, when I attempt to normalize on level 1 of the columns as follows:
I get an error:
Weirdly, it works fine if I use up to 3 of the values of level 1 of axis 1, for example:
which just takes the first 3 sets of values from the sample:
Then:
correctly returns:
Any idea why the latter works and the former doesn't? I'm using Pandas version 0.16.1 |
|
I see, that does indeed work, thanks so much for the help. I am a bit confused by the documentation then. The docstring for transform says: Call function producing a like-indexed DataFrame on each group and So I assumed that transform would return a "transformed" dataframe for each group. In any case, now I think I have a better understanding of apply. Thanks again! |
yes, that the result of a transform. a user-defined function needs to return a single (scalar) value. hmm, maybe be better to have a nicer error message / doc. going to make an issue. |
Replicating Example (pandas 15.2 and 0.16.0rc1-32-g5a417ec):
Error:
Traceback (most recent call last):
The text was updated successfully, but these errors were encountered: