Skip to content

Commit 605d446

Browse files
authored
REF: avoid passing silently-ignored kwargs to Resampler (#51149)
1 parent 6d6cccc commit 605d446

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

pandas/core/resample.py

+4-17
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ def __init__(
151151
*,
152152
group_keys: bool | lib.NoDefault = lib.no_default,
153153
selection=None,
154-
**kwargs,
155154
) -> None:
156155
self._timegrouper = groupby
157156
self.keys = None
@@ -171,18 +170,6 @@ def __init__(
171170
else:
172171
self.exclusions = frozenset()
173172

174-
@final
175-
def _shallow_copy(self, obj, **kwargs):
176-
"""
177-
return a new object with the replacement attributes
178-
"""
179-
if isinstance(obj, self._constructor):
180-
obj = obj.obj
181-
for attr in self._attributes:
182-
if attr not in kwargs:
183-
kwargs[attr] = getattr(self, attr)
184-
return self._constructor(obj, **kwargs)
185-
186173
def __str__(self) -> str:
187174
"""
188175
Provide a nice str repr of our rolling object.
@@ -1181,7 +1168,7 @@ def _apply(self, f, *args, **kwargs):
11811168
"""
11821169

11831170
def func(x):
1184-
x = self._shallow_copy(x, groupby=self._timegrouper)
1171+
x = self._resampler_cls(x, groupby=self._timegrouper)
11851172

11861173
if isinstance(f, str):
11871174
return getattr(x, f)(**kwargs)
@@ -1364,7 +1351,7 @@ class DatetimeIndexResamplerGroupby(_GroupByMixin, DatetimeIndexResampler):
13641351
"""
13651352

13661353
@property
1367-
def _constructor(self):
1354+
def _resampler_cls(self):
13681355
return DatetimeIndexResampler
13691356

13701357

@@ -1476,7 +1463,7 @@ class PeriodIndexResamplerGroupby(_GroupByMixin, PeriodIndexResampler):
14761463
"""
14771464

14781465
@property
1479-
def _constructor(self):
1466+
def _resampler_cls(self):
14801467
return PeriodIndexResampler
14811468

14821469

@@ -1504,7 +1491,7 @@ class TimedeltaIndexResamplerGroupby(_GroupByMixin, TimedeltaIndexResampler):
15041491
"""
15051492

15061493
@property
1507-
def _constructor(self):
1494+
def _resampler_cls(self):
15081495
return TimedeltaIndexResampler
15091496

15101497

0 commit comments

Comments
 (0)