Skip to content

Commit 00e10a5

Browse files
authored
REF: always use grouper=self.grouper in resample (#43484)
1 parent c4b43cc commit 00e10a5

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pandas/core/resample.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,7 @@ def aggregate(self, func=None, *args, **kwargs):
338338
result = ResamplerWindowApply(self, func, args=args, kwargs=kwargs).agg()
339339
if result is None:
340340
how = func
341-
grouper = None
342-
result = self._groupby_and_aggregate(how, grouper, *args, **kwargs)
341+
result = self._groupby_and_aggregate(how, *args, **kwargs)
343342

344343
result = self._apply_loffset(result)
345344
return result
@@ -409,12 +408,11 @@ def _gotitem(self, key, ndim: int, subset=None):
409408
except KeyError:
410409
return grouped
411410

412-
def _groupby_and_aggregate(self, how, grouper=None, *args, **kwargs):
411+
def _groupby_and_aggregate(self, how, *args, **kwargs):
413412
"""
414413
Re-evaluate the obj with a groupby aggregation.
415414
"""
416-
if grouper is None:
417-
grouper = self.grouper
415+
grouper = self.grouper
418416

419417
obj = self._selected_obj
420418

@@ -1055,7 +1053,7 @@ def __init__(self, obj, parent=None, groupby=None, **kwargs):
10551053
self.groupby = copy.copy(parent.groupby)
10561054

10571055
@no_type_check
1058-
def _apply(self, f, grouper=None, *args, **kwargs):
1056+
def _apply(self, f, *args, **kwargs):
10591057
"""
10601058
Dispatch to _upsample; we are stripping all of the _upsample kwargs and
10611059
performing the original function call on the grouped object.
@@ -1296,15 +1294,15 @@ def _downsample(self, how, **kwargs):
12961294

12971295
if is_subperiod(ax.freq, self.freq):
12981296
# Downsampling
1299-
return self._groupby_and_aggregate(how, grouper=self.grouper, **kwargs)
1297+
return self._groupby_and_aggregate(how, **kwargs)
13001298
elif is_superperiod(ax.freq, self.freq):
13011299
if how == "ohlc":
13021300
# GH #13083
13031301
# upsampling to subperiods is handled as an asfreq, which works
13041302
# for pure aggregating/reducing methods
13051303
# OHLC reduces along the time dimension, but creates multiple
13061304
# values for each period -> handle by _groupby_and_aggregate()
1307-
return self._groupby_and_aggregate(how, grouper=self.grouper)
1305+
return self._groupby_and_aggregate(how)
13081306
return self.asfreq()
13091307
elif ax.freq == self.freq:
13101308
return self.asfreq()

0 commit comments

Comments
 (0)