Skip to content

Commit

Permalink
BUG: DatetimeIndex.join tz-aware issue with how='outer'. close #2317
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Nov 24, 2012
1 parent bb8abd7 commit f29106d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ pandas 0.10.0
- Raise exception on calling reset_index on Series with inplace=True (#2277)
- Enable setting multiple columns in DataFrame with hierarchical columns
(#2295)
- Respect dtype=object in DataFrame constructor (#2291)
- Fix DatetimeIndex.join bug with tz-aware indexes and how='outer' (#2317)

pandas 0.9.1
============
Expand Down
2 changes: 1 addition & 1 deletion pandas/tseries/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ def _wrap_joined_index(self, joined, other):
return joined
else:
tz = getattr(other, 'tz', None)
return DatetimeIndex(joined, name=name, tz=tz)
return self._simple_new(joined, name, tz=tz)

def _can_fast_union(self, other):
if not isinstance(other, DatetimeIndex):
Expand Down
16 changes: 15 additions & 1 deletion pandas/tseries/tests/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ def test_join_utc_convert(self):
self.assert_(isinstance(result, DatetimeIndex))
self.assert_(result.tz.zone == 'UTC')

def test_join_naive_with_aware(self):
def test_join_aware(self):
rng = date_range('1/1/2011', periods=10, freq='H')
ts = Series(np.random.randn(len(rng)), index=rng)

Expand All @@ -631,6 +631,20 @@ def test_join_naive_with_aware(self):
self.assertRaises(Exception, ts.__add__, ts_utc)
self.assertRaises(Exception, ts_utc.__add__, ts)

test1 = DataFrame(np.zeros((6,3)),
index=date_range("2012-11-15 00:00:00", periods=6,
freq="100L", tz="US/Central"))
test2 = DataFrame(np.zeros((3,3)),
index=date_range("2012-11-15 00:00:00", periods=3,
freq="250L", tz="US/Central"),
columns=range(3,6))

result = test1.join(test2, how='outer')
ex_index = test1.index.union(test2.index)

self.assertTrue(result.index.equals(ex_index))
self.assertTrue(result.index.tz.zone == 'US/Central')

def test_align_aware(self):
idx1 = date_range('2001', periods=5, freq='H', tz='US/Eastern')
idx2 = date_range('2001', periods=5, freq='2H', tz='US/Eastern')
Expand Down

0 comments on commit f29106d

Please sign in to comment.