Skip to content

Commit 68a02aa

Browse files
authored
!B [pandas-dev#15549] resample with tz-aware: Values falls after last bin
1 parent cd67704 commit 68a02aa

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pandas/tseries/resample.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1144,17 +1144,18 @@ def _get_time_bins(self, ax):
11441144
if not isinstance(ax, DatetimeIndex):
11451145
raise TypeError('axis must be a DatetimeIndex, but got '
11461146
'an instance of %r' % type(ax).__name__)
1147-
11481147
if len(ax) == 0:
11491148
binner = labels = DatetimeIndex(
11501149
data=[], freq=self.freq, name=ax.name)
11511150
return binner, [], labels
1152-
1151+
1152+
tz = ax.tz
1153+
ax = ax.tz_convert('UTC')
1154+
11531155
first, last = ax.min(), ax.max()
11541156
first, last = _get_range_edges(first, last, self.freq,
11551157
closed=self.closed,
11561158
base=self.base)
1157-
tz = ax.tz
11581159
# GH #12037
11591160
# use first/last directly instead of call replace() on them
11601161
# because replace() will swallow the nanosecond part
@@ -1163,8 +1164,7 @@ def _get_time_bins(self, ax):
11631164
binner = labels = DatetimeIndex(freq=self.freq,
11641165
start=first,
11651166
end=last,
1166-
tz=tz,
1167-
name=ax.name)
1167+
name=ax.name).tz_convert(tz)
11681168

11691169
# a little hack
11701170
trimmed = False

0 commit comments

Comments
 (0)