Skip to content

Commit

Permalink
BUG: DatetimeIndex.intersection issue with equal unanchored offsets c…
Browse files Browse the repository at this point in the history
…lose #1708
  • Loading branch information
wesm committed Aug 10, 2012
1 parent 5b3853d commit eb3c4e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions RELEASE.rst
Expand Up @@ -39,6 +39,7 @@ pandas 0.8.2
**Bug fixes**

- Fix critical DatetimeIndex.union bugs (#1730, #1719, #1745, #1702)
- Fix critical DatetimeIndex.intersection bug with unanchored offsets (#1708)
- Fix MM-YYYY time series indexing case (#1672)
- Fix case where Categorical group key was not being passed into index in
GroupBy result (#1701)
Expand Down
1 change: 1 addition & 0 deletions pandas/tseries/index.py
Expand Up @@ -834,6 +834,7 @@ def intersection(self, other):

elif (other.offset is None or self.offset is None or
other.offset != self.offset or
not other.offset.isAnchored() or
(not self.is_monotonic or not other.is_monotonic)):
result = Index.intersection(self, other)
if isinstance(result, DatetimeIndex):
Expand Down
8 changes: 8 additions & 0 deletions pandas/tseries/tests/test_timeseries.py
Expand Up @@ -1179,6 +1179,14 @@ def test_union_bug_1745(self):
exp = DatetimeIndex(sorted(set(list(left)) | set(list(right))))
self.assert_(result.equals(exp))

def test_intersection_bug_1708(self):
from pandas import DateOffset
index_1 = date_range('1/1/2012', periods=4, freq='12H')
index_2 = index_1 + DateOffset(hours=1)

result = index_1 & index_2
self.assertEqual(len(result), 0)

# def test_add_timedelta64(self):
# rng = date_range('1/1/2000', periods=5)
# delta = rng.values[3] - rng.values[1]
Expand Down

0 comments on commit eb3c4e6

Please sign in to comment.