Skip to content

Commit 8265c7d

Browse files
committed
Updated condition logic
1 parent 1c545b9 commit 8265c7d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pandas/core/indexes/datetimelike.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,7 @@ def _fast_intersect(self, other, sort):
626626
return result
627627

628628
def _can_fast_intersect(self, other: Self) -> bool:
629-
# Note: we only get here with len(self) > 0 and len(other) > 0
630-
if self.freq is None or self.freq == "C":
629+
if self.freq is None:
631630
return False
632631

633632
elif other.freq != self.freq:
@@ -637,6 +636,13 @@ def _can_fast_intersect(self, other: Self) -> bool:
637636
# Because freq is not None, we must then be monotonic decreasing
638637
return False
639638

639+
# for non-anchored frequencies, need to check that the two
640+
# indexes actually share a common point
641+
# GH#44025
642+
diff = other[0] - self[0]
643+
if diff != Timedelta(0) and diff.total_seconds() % 86400 != 0:
644+
return False
645+
640646
# this along with matching freqs ensure that we "line up",
641647
# so intersection will preserve freq
642648
# Note we are assuming away Ticks, as those go through _range_intersect

0 commit comments

Comments
 (0)