-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
groupby().agg() calls the user function for an extra time with empty inputs in 1.0.0 #31760
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
@jbrockmendel looks related to one of your changes 08087d6. Is this avoidable? |
Hi thanks for the response! Do we think this is a bug and that we should restore the original behavior? |
Not really. This behavior has been in place for groupby.apply for a while. |
I am not it's true that the behavior has been in place for a while. As far as I can tell this is behavior introduced in 1.0.0, which has just been released. Also this behavior doesn't totally make sense to me - why groupby.agg() needs to call the user function with empty input, it feels like a side effect of the implementation detail and not really an intentional behavior change to improve user ability. I fully respect your decision but want to explore here whether this is the correct thing to do. We do find this new behavior breaking our existing code. |
@jbrockmendel this appears to be a regression |
I was referring to previously-existing behavior in
We have a fastpath that goes through cython and a slowpath that stays in python. The call on an empty input is part of an attempt to figure out if we can go through the fastpath. (FWIW, I'm increasingly of the opinion that the cython fastpath isnt worth the maintenance burden)
As of the last time I worked on this code (circa October I think) this was chosen as the least-bad option available. If you'd like to make a PR with a better alternative, go for it. |
@jbrockmendel something broke in 1.0.x for .agg @WillAyd maybe have some insight as iirc some of this was touched |
I think #32083 would address this. |
hmm that’s pretty big to backport |
Code Sample, a copy-pastable example if possible
Problem description
In 1.0.0, this code outputs:
In 0.25.3, the code outputs:
In 1.0.0,
foo
is called one more time with empty input, which can break user codeNote: We receive a lot of issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates!
Note: Many problems can be resolved by simply upgrading
pandas
to the latest version. Before submitting, please check if that solution works for you. If possible, you may want to check ifmaster
addresses this issue, but that is not necessary.For documentation-related issues, you can check the latest versions of the docs on
master
here:https://pandas-docs.github.io/pandas-docs-travis/
If the issue has not been resolved there, go ahead and file it in the issue tracker.
Expected Output
Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here below this line]The text was updated successfully, but these errors were encountered: