Skip to content

Commit 46bf933

Browse files
committed
Merge branch 'dt_index_fix' of https://github.com/filmor/pandas into filmor-dt_index_fix
Conflicts: doc/source/release.rst
2 parents 7c76086 + 3584e50 commit 46bf933

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

doc/source/release.rst

+1
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ Bug Fixes
472472
- Fixed skiprows option in Python parser for read_csv (:issue:`4382`)
473473
- Fixed bug preventing ``cut`` from working with ``np.inf`` levels without
474474
explicitly passing labels (:issue:`3415`)
475+
- Fixed wrong check for overlapping in ``DatetimeIndex.union`` (:issue:`4564`)
475476

476477
pandas 0.12.0
477478
-------------

pandas/tseries/index.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -986,11 +986,11 @@ def _can_fast_union(self, other):
986986
else:
987987
left, right = other, self
988988

989-
left_end = left[-1]
990989
right_start = right[0]
990+
left_end = left[-1]
991991

992992
# Only need to "adjoin", not overlap
993-
return (left_end + offset) >= right_start
993+
return (right_start == left_end + offset) or right_start in left
994994

995995
def _fast_union(self, other):
996996
if len(other) == 0:

pandas/tseries/tests/test_timeseries.py

+9
Original file line numberDiff line numberDiff line change
@@ -1859,6 +1859,15 @@ def test_union_bug_1745(self):
18591859
exp = DatetimeIndex(sorted(set(list(left)) | set(list(right))))
18601860
self.assert_(result.equals(exp))
18611861

1862+
def test_union_bug_4564(self):
1863+
from pandas import DateOffset
1864+
left = date_range("2013-01-01", "2013-02-01")
1865+
right = left + DateOffset(minutes=15)
1866+
1867+
result = left.union(right)
1868+
exp = DatetimeIndex(sorted(set(list(left)) | set(list(right))))
1869+
self.assert_(result.equals(exp))
1870+
18621871
def test_intersection_bug_1708(self):
18631872
from pandas import DateOffset
18641873
index_1 = date_range('1/1/2012', periods=4, freq='12H')

0 commit comments

Comments
 (0)