Skip to content

Update resample.py #59353

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

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 18 additions & 0 deletions pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,24 @@ class DatetimeIndexResampler(Resampler):
def _resampler_for_grouping(self) -> type[DatetimeIndexResamplerGroupby]:
return DatetimeIndexResamplerGroupby

def _get_resampler_for_grouping(self, groupby, how, fill_method, limit, kind):
"""
Return a resampler for groupby object.
"""
self.groupby = groupby
self._on = getattr(groupby, 'on', None)
if self._on is not None:
groupby._selected_obj = groupby._selected_obj.reset_index(drop=True).set_index(self._on)
return self._get_resampler(how, fill_method, limit, kind)

def _get_resampler(self, how, fill_method, limit, kind):
"""
Return a resampler for non-groupby object.
"""
if self._on is not None:
self._selected_obj = self._selected_obj.reset_index(drop=True).set_index(self._on)
return super()._get_resampler(how, fill_method, limit, kind)

def _get_binner_for_time(self):
# this is how we are actually creating the bins
if isinstance(self.ax, PeriodIndex):
Expand Down
Loading