-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Behavior change of 1.4.rc0 when group by apply
returns a copy of the passed data frame
#45315
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
apply
returns frames with multi-indexapply
returns a copy of the passed data frame
It seems my analysis is not really correct. What is passed to the apply func seems to be unchanged. It is just that formerly returning a copy created a frame with a multi-index while this does not happen anymore? The behavior when just returning what is passed ( |
cc @rhshadrach if u could have a quick look |
@aberres - thanks for the report! The change here was not intentional, in that it was an behavior change that was not noticed until after it was merged and without a deprecation notice. However, it does move pandas in the right direction of consistency, and would be very hard to revert, so I am +1 on moving forward with the behavior in 1.4 as-is.
Being able to control what happens with the group keys in apply (regardless of whether pandas detects a transform) would be resolved by #34998. |
Thanks @rhshadrach should we close this or leave open until #34998 is merged and move off 1.4 milestone? |
Thinking some more, it's not too late to add something to the release notes about the breaking change. |
That sounds good @simonjayhawkins - I should be able to get a PR up by the end of today. |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
Issue Description
While testing our code base against 1.4rc0 I stumbled upon a behavior change of Pandas 1.4.
Formerly when
apply
was called on a grouper it seems as if a returned multi-index was honored in the resulting data frame.With 1.4 the index is dropped.
No idea if this is an intentional change or not. Wanted to let you know to be on the safe side.
also did not check why or code does what it does (the method called in apply is pretty complex, not just a copy). Looks a bit fishy...
Expected Behavior
Unchanged behavior.
Installed Versions
Replace this line with the output of pd.show_versions()
The text was updated successfully, but these errors were encountered: