Skip to content

Commit bd34795

Browse files
committed
BUG: fix tz-aware resampling issue. close #2245
1 parent e374f0f commit bd34795

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

RELEASE.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ pandas 0.9.1
103103
- Fix conversion of mixed-type DataFrame to ndarray with dup columns (#2236)
104104
- Fix duplicate columns issue (#2218, #2219)
105105
- Fix SparseSeries.__pow__ issue with NA input (#2220)
106+
- Fix icol with integer sequence failure (#2228)
107+
- Fixed resampling tz-aware time series issue (#2245)
106108
107109
pandas 0.9.0
108110
============

pandas/tseries/resample.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ def _get_time_bins(self, axis):
110110

111111
first, last = _get_range_edges(axis, self.freq, closed=self.closed,
112112
base=self.base)
113-
binner = labels = DatetimeIndex(freq=self.freq, start=first, end=last)
113+
tz = axis.tz
114+
binner = labels = DatetimeIndex(freq=self.freq,
115+
start=first.replace(tzinfo=None),
116+
end=last.replace(tzinfo=None), tz=tz)
114117

115118
# a little hack
116119
trimmed = False

pandas/tseries/tests/test_resample.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,24 @@ def test_resample_tz_localized(self):
823823
# it works
824824
result = ts_local.resample('D')
825825

826+
# #2245
827+
idx = date_range('2001-09-20 15:59','2001-09-20 16:00', freq='T',
828+
tz='Australia/Sydney')
829+
s = Series([1,2], index=idx)
830+
831+
result = s.resample('D')
832+
ex_index = date_range('2001-09-21', periods=1, freq='D',
833+
tz='Australia/Sydney')
834+
expected = Series([1.5], index=ex_index)
835+
836+
assert_series_equal(result, expected)
837+
838+
# for good measure
839+
result = s.resample('D', kind='period')
840+
ex_index = period_range('2001-09-20', periods=1, freq='D')
841+
expected = Series([1.5], index=ex_index)
842+
assert_series_equal(result, expected)
843+
826844
def test_closed_left_corner(self):
827845
# #1465
828846
s = Series(np.random.randn(21),

0 commit comments

Comments
 (0)