From 2e852c8e24c1285cc77e5f0b6ea69e53f6ccb202 Mon Sep 17 00:00:00 2001 From: Richard Shadrach Date: Mon, 16 Dec 2024 17:14:34 -0500 Subject: [PATCH] Inline _apply --- pandas/core/resample.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pandas/core/resample.py b/pandas/core/resample.py index 934816f82472d..27e498683bf8f 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -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): @@ -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) @@ -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 @@ -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