Skip to content

REF: simplify kwargs unpacking in resample #41235

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 2 commits into from
Apr 30, 2021
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
10 changes: 3 additions & 7 deletions pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,11 +1046,9 @@ class _GroupByMixin(PandasObject):

_attributes: list[str] # in practice the same as Resampler._attributes

def __init__(self, obj, **kwargs):
def __init__(self, obj, parent=None, groupby=None, **kwargs):
# reached via ._gotitem and _get_resampler_for_grouping

parent = kwargs.pop("parent", None)
groupby = kwargs.pop("groupby", None)
if parent is None:
parent = obj

Expand Down Expand Up @@ -1416,15 +1414,13 @@ def get_resampler(obj, kind=None, **kwds):


def get_resampler_for_grouping(
groupby, rule, how=None, fill_method=None, limit=None, kind=None, **kwargs
groupby, rule, how=None, fill_method=None, limit=None, kind=None, on=None, **kwargs
):
"""
Return our appropriate resampler when grouping as well.
"""
# .resample uses 'on' similar to how .groupby uses 'key'
kwargs["key"] = kwargs.pop("on", None)

tg = TimeGrouper(freq=rule, **kwargs)
tg = TimeGrouper(freq=rule, key=on, **kwargs)
resampler = tg._get_resampler(groupby.obj, kind=kind)
return resampler._get_resampler_for_grouping(groupby=groupby)

Expand Down