-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF: Apply.apply_multiple #53362
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
REF: Apply.apply_multiple #53362
Conversation
pandas/core/apply.py
Outdated
@@ -554,7 +561,20 @@ def apply_multiple(self) -> DataFrame | Series: | |||
result: Series, DataFrame, or None | |||
Result when self.f is a list-like or dict-like, None otherwise. | |||
""" | |||
return self.obj.aggregate(self.f, self.axis, *self.args, **self.kwargs) | |||
if self.axis == 1 and isinstance(self.obj, ABCDataFrame): | |||
return self.obj.T.apply(self.f, 0, *self.args, **self.kwargs).T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be args=self.args
, not *self.args
. Can you add a test here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good catch. Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
A step towards fixing #53325 (comment).
This avoids the need to call out into
(Series|DataFrame).aggregate
. In a follow-up I will replace the use ofagg_(list|dict)_like
withapply
specific versions of those methds or some similar solution, avoiding needing to callApply.agg
from withinApply.apply_multiple
.CC @rhshadrach