Skip to content

Commit 7b9af4a

Browse files
rhshadrachpmhatre1
authored andcommitted
CLN: Remove unnecessary block in apply_str (pandas-dev#58077)
1 parent c030abf commit 7b9af4a

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

pandas/core/apply.py

+4-16
Original file line numberDiff line numberDiff line change
@@ -564,22 +564,10 @@ def apply_str(self) -> DataFrame | Series:
564564
"axis" not in arg_names or func in ("corrwith", "skew")
565565
):
566566
raise ValueError(f"Operation {func} does not support axis=1")
567-
if "axis" in arg_names:
568-
if isinstance(obj, (SeriesGroupBy, DataFrameGroupBy)):
569-
# Try to avoid FutureWarning for deprecated axis keyword;
570-
# If self.axis matches the axis we would get by not passing
571-
# axis, we safely exclude the keyword.
572-
573-
default_axis = 0
574-
if func in ["idxmax", "idxmin"]:
575-
# DataFrameGroupBy.idxmax, idxmin axis defaults to self.axis,
576-
# whereas other axis keywords default to 0
577-
default_axis = self.obj.axis
578-
579-
if default_axis != self.axis:
580-
self.kwargs["axis"] = self.axis
581-
else:
582-
self.kwargs["axis"] = self.axis
567+
if "axis" in arg_names and not isinstance(
568+
obj, (SeriesGroupBy, DataFrameGroupBy)
569+
):
570+
self.kwargs["axis"] = self.axis
583571
return self._apply_str(obj, func, *self.args, **self.kwargs)
584572

585573
def apply_list_or_dict_like(self) -> DataFrame | Series:

0 commit comments

Comments
 (0)