Skip to content

Commit 6b5be05

Browse files
committed
BUG: fix time zone handling in union between non-overlapping DatetimeIndex. close #2367
1 parent 537e6a6 commit 6b5be05

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

RELEASE.rst

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ pandas 0.10.0
7777
something weird) (#2263)
7878
- Prevent uint64 -> int64 overflows (#2355)
7979
- Enable joins between MultiIndex and regular Index (#2024)
80+
- Fix time zone metadata issue when unioning non-overlapping DatetimeIndex
81+
objects (#2367)
8082

8183
pandas 0.9.1
8284
============

pandas/tseries/index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ def union(self, other):
824824
else:
825825
result = Index.union(this, other)
826826
if isinstance(result, DatetimeIndex):
827-
result.tz = self.tz
827+
result.tz = this.tz
828828
if result.freq is None:
829829
result.offset = to_offset(result.inferred_freq)
830830
return result

pandas/tseries/tests/test_timezones.py

+10
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,16 @@ def test_join_aware(self):
645645
self.assertTrue(result.index.equals(ex_index))
646646
self.assertTrue(result.index.tz.zone == 'US/Central')
647647

648+
# non-overlapping
649+
rng = date_range("2012-11-15 00:00:00", periods=6,
650+
freq="H", tz="US/Central")
651+
652+
rng2 = date_range("2012-11-15 12:00:00", periods=6,
653+
freq="H", tz="US/Eastern")
654+
655+
result = rng.union(rng2)
656+
self.assertTrue(result.tz.zone == 'UTC')
657+
648658
def test_align_aware(self):
649659
idx1 = date_range('2001', periods=5, freq='H', tz='US/Eastern')
650660
idx2 = date_range('2001', periods=5, freq='2H', tz='US/Eastern')

0 commit comments

Comments
 (0)