Skip to content

Commit

Permalink
Inline _apply
Browse files Browse the repository at this point in the history
  • Loading branch information
rhshadrach committed Dec 16, 2024
1 parent bef36c1 commit 2e852c8
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def _groupby_and_aggregate(self, how, *args, **kwargs):
# a DataFrame column, but aggregate_item_by_item operates column-wise
# on Series, raising AttributeError or KeyError
# (depending on whether the column lookup uses getattr/__getitem__)
result = _apply(grouped, how, *args, **kwargs)
result = grouped.apply(how, *args, **kwargs)

except ValueError as err:
if "Must produce aggregated value" in str(err):
Expand All @@ -474,7 +474,7 @@ def _groupby_and_aggregate(self, how, *args, **kwargs):

# we have a non-reducing function
# try to evaluate
result = _apply(grouped, how, *args, **kwargs)
result = grouped.apply(how, *args, **kwargs)

return self._wrap_result(result)

Expand Down Expand Up @@ -1576,7 +1576,7 @@ def func(x):

return x.apply(f, *args, **kwargs)

result = _apply(self._groupby, func)
result = self._groupby.apply(func)
return self._wrap_result(result)

_upsample = _apply
Expand Down Expand Up @@ -2719,8 +2719,3 @@ def _asfreq_compat(index: FreqIndexT, freq) -> FreqIndexT:
else: # pragma: no cover
raise TypeError(type(index))
return new_index


def _apply(grouped: GroupBy, how: Callable, *args, **kwargs) -> DataFrame:
result = grouped.apply(how, *args, **kwargs)
return result

0 comments on commit 2e852c8

Please sign in to comment.