Skip to content

REF: avoid passing silently-ignored kwargs to Resampler #51149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 4, 2023
Merged
Changes from all commits
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
21 changes: 4 additions & 17 deletions pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ def __init__(
*,
group_keys: bool | lib.NoDefault = lib.no_default,
selection=None,
**kwargs,
) -> None:
self._timegrouper = groupby
self.keys = None
Expand All @@ -171,18 +170,6 @@ def __init__(
else:
self.exclusions = frozenset()

@final
def _shallow_copy(self, obj, **kwargs):
"""
return a new object with the replacement attributes
"""
if isinstance(obj, self._constructor):
obj = obj.obj
for attr in self._attributes:
if attr not in kwargs:
kwargs[attr] = getattr(self, attr)
return self._constructor(obj, **kwargs)

def __str__(self) -> str:
"""
Provide a nice str repr of our rolling object.
Expand Down Expand Up @@ -1181,7 +1168,7 @@ def _apply(self, f, *args, **kwargs):
"""

def func(x):
x = self._shallow_copy(x, groupby=self._timegrouper)
x = self._resampler_cls(x, groupby=self._timegrouper)

if isinstance(f, str):
return getattr(x, f)(**kwargs)
Expand Down Expand Up @@ -1364,7 +1351,7 @@ class DatetimeIndexResamplerGroupby(_GroupByMixin, DatetimeIndexResampler):
"""

@property
def _constructor(self):
def _resampler_cls(self):
return DatetimeIndexResampler


Expand Down Expand Up @@ -1476,7 +1463,7 @@ class PeriodIndexResamplerGroupby(_GroupByMixin, PeriodIndexResampler):
"""

@property
def _constructor(self):
def _resampler_cls(self):
return PeriodIndexResampler


Expand Down Expand Up @@ -1504,7 +1491,7 @@ class TimedeltaIndexResamplerGroupby(_GroupByMixin, TimedeltaIndexResampler):
"""

@property
def _constructor(self):
def _resampler_cls(self):
return TimedeltaIndexResampler


Expand Down