Skip to content

Commit

Permalink
CLN: Remove unnecessary block in apply_str (#58077)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhshadrach committed Mar 29, 2024
1 parent b63ae8c commit 9088006
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,22 +564,10 @@ def apply_str(self) -> DataFrame | Series:
"axis" not in arg_names or func in ("corrwith", "skew")
):
raise ValueError(f"Operation {func} does not support axis=1")
if "axis" in arg_names:
if isinstance(obj, (SeriesGroupBy, DataFrameGroupBy)):
# Try to avoid FutureWarning for deprecated axis keyword;
# If self.axis matches the axis we would get by not passing
# axis, we safely exclude the keyword.

default_axis = 0
if func in ["idxmax", "idxmin"]:
# DataFrameGroupBy.idxmax, idxmin axis defaults to self.axis,
# whereas other axis keywords default to 0
default_axis = self.obj.axis

if default_axis != self.axis:
self.kwargs["axis"] = self.axis
else:
self.kwargs["axis"] = self.axis
if "axis" in arg_names and not isinstance(
obj, (SeriesGroupBy, DataFrameGroupBy)
):
self.kwargs["axis"] = self.axis
return self._apply_str(obj, func, *self.args, **self.kwargs)

def apply_list_or_dict_like(self) -> DataFrame | Series:
Expand Down

0 comments on commit 9088006

Please sign in to comment.