Skip to content

_get_new_index always returns index in PeriodIndexResampler #12875

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
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
8 changes: 3 additions & 5 deletions pandas/tseries/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,11 +675,9 @@ def _get_new_index(self):
ax = self.ax
ax_attrs = ax._get_attributes_dict()
ax_attrs['freq'] = self.freq
obj = self._selected_obj

if len(ax) == 0:
new_index = PeriodIndex(data=[], **ax_attrs)
return obj.reindex(new_index)
return PeriodIndex(data=[], **ax_attrs)

start = ax[0].asfreq(self.freq, how=self.convention)
end = ax[-1].asfreq(self.freq, how='end')
Expand All @@ -705,7 +703,7 @@ def _downsample(self, how, **kwargs):

new_index = self._get_new_index()
if len(new_index) == 0:
return self._wrap_result(new_index)
return self._wrap_result(self._selected_obj.reindex(new_index))

# Start vs. end of period
memb = ax.asfreq(self.freq, how=self.convention)
Expand Down Expand Up @@ -746,7 +744,7 @@ def _upsample(self, method, limit=None):

new_index = self._get_new_index()
if len(new_index) == 0:
return self._wrap_result(new_index)
return self._wrap_result(self._selected_obj.reindex(new_index))

if not is_superperiod(ax.freq, self.freq):
return self.asfreq()
Expand Down