Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
ABCSeries,
)

from pandas.core.base import SelectionMixin
import pandas.core.common as com
from pandas.core.construction import ensure_wrapped_if_datetimelike

Expand Down Expand Up @@ -359,19 +358,7 @@ def agg_or_apply_list_like(
if getattr(obj, "axis", 0) == 1:
raise NotImplementedError("axis other than 0 is not supported")

selected_obj = obj
if not isinstance(obj, SelectionMixin):
# i.e. obj is Series or DataFrame
selected_obj = obj
elif obj._selected_obj.ndim == 1:
assert False
# For SeriesGroupBy this matches _obj_with_exclusions
selected_obj = obj._selected_obj
else:
assert False
selected_obj = obj._obj_with_exclusions

keys, results = self.compute_list_like(op_name, selected_obj, kwargs)
keys, results = self.compute_list_like(op_name, obj, kwargs)
result = self.wrap_results_list_like(keys, results)
return result

Expand Down Expand Up @@ -465,6 +452,7 @@ def agg_or_apply_dict_like(
assert op_name in ["agg", "apply"]

obj = self.obj
assert isinstance(obj, (ABCSeries, ABCDataFrame))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this method to NDFrameApply?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: if your idea is to make Apply.obj only be Series | DataFrame then there's no reason to ove because I guess you will want to merge Apply with NDFrameApply later?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved this to NDFrameApply


kwargs = {}
if op_name == "apply":
Expand All @@ -474,14 +462,11 @@ def agg_or_apply_dict_like(
if getattr(obj, "axis", 0) == 1:
raise NotImplementedError("axis other than 0 is not supported")

selected_obj = obj
assert isinstance(selected_obj, (ABCSeries, ABCDataFrame))
selection = None

result_index, result_data = self.compute_dict_like(
op_name, selected_obj, selection, kwargs
op_name, obj, selection, kwargs
)
result = self.wrap_results_dict_like(selected_obj, result_index, result_data)
result = self.wrap_results_dict_like(obj, result_index, result_data)
return result

def wrap_results_dict_like(
Expand Down