Skip to content

BUG: Correctly weekly resample over DST #22941

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 7 commits into from
Oct 3, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
move the localization until needed
  • Loading branch information
Matt Roeschke committed Oct 1, 2018
commit bce52a56ad1d3cc60ff473f23c46750872646f62
28 changes: 27 additions & 1 deletion pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ def _get_time_bins(self, ax):
labels = labels[:len(bins)]

return binner, bins, labels

"""
def _adjust_bin_edges(self, binner, ax_values):
# Some hacks for > daily data, see #1471, #1458, #1483
#import pdb; pdb.set_trace()
Expand All @@ -1415,6 +1415,7 @@ def _adjust_bin_edges(self, binner, ax_values):

return binner, bin_edges
"""
"""
def _adjust_bin_edges(self, binner, ax_values):
# Some hacks for > daily data, see #1471, #1458, #1483
if binner.tz is not None:
Expand All @@ -1435,6 +1436,31 @@ def _adjust_bin_edges(self, binner, ax_values):
bin_edges = tz_localize_to_utc(bin_edges, binner.tz)
return binner, bin_edges
"""
def _adjust_bin_edges(self, binner, ax_values):
# Some hacks for > daily data, see #1471, #1458, #1483

bin_edges = binner.asi8

if self.freq != 'D' and is_superperiod(self.freq, 'D'):
day_nanos = delta_to_nanoseconds(timedelta(1))
if self.closed == 'right':
if binner.tz is not None:
bin_edges = binner.tz_localize(None).asi8
else:
bin_edges = binner.asi8
bin_edges = bin_edges + day_nanos - 1

if binner.tz is not None:
bin_edges = tz_localize_to_utc(bin_edges, binner.tz)

# intraday values on last day
if bin_edges[-2] > ax_values.max():
bin_edges = bin_edges[:-1]
binner = binner[:-1]
return binner, bin_edges
else:
return binner, binner.asi8

def _get_time_delta_bins(self, ax):
if not isinstance(ax, TimedeltaIndex):
raise TypeError('axis must be a TimedeltaIndex, but got '
Expand Down