-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: passing kwargs to Series.aggregate raises TypeError: f() got an unexpected keyword argument #43357
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
Thanks @jakeanq for the report. It appears that the function is now applied to each value instead of the Series as a whole. (i.e. applied along the wrong axis, The axis keyword is for compatibility with DataFrame and axis=1 raises an error) first bad commit: [fad5fee] CLN: Move the rest of Series.apply into apply (#39954) cc @rhshadrach code sample
on 1.2.5
on 1.3.2
|
Series.agg will first try row-by-row using apply. If this fails, it will fallback to aggregating the entire Series. I believe this is the behavior we need to maintain (but am currently working on removing it for future versions). |
Expanding on my previous comment, the example @simonjayhawkins posted is failing in the attempt to use apply because of a bug. The call is:
But apply accepts the argument
Both of these produce on 1.2.x:
While it's possible to preserve the erroneous |
Thanks @rhshadrach for investigating this further. My code sample should maybe have been a separate issue. using semver, we can indeed also fix bugs on 1.3.x, especially if it makes sense to fix these issues together. |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas. The bug is present on 1.3.0, 1.3.1 and 1.3.2 but not 1.2.5.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Problem description
Prior to Pandas 1.3.0, it was possible to pass kwargs when using Series.aggregate, however it appears that Pandas now attempts to apply the arguments and keyword arguments twice (first currying them then using them to call the curried function).
Expected Output
Expect output is the program running normally and not throwing an exception.
Actual Output
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: