BUG: DatetimeIndex.intersection with non-anchored freq · Issue #44025 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
import pandas as pd
off = pd.offsets.CDay(1, False)
ts = pd.Timestamp("2021-10-13 09") ts2 = ts + pd.Timedelta("1 hour")
dti = pd.date_range(start=ts, periods=10, freq=off) dti2 = pd.date_range(start=ts2, periods=10, freq=off)
assert set(dti).intersection(set(dti2)) == set() # yep!
res = dti.intersection(dti2) assert len(res) == 0 # nope!
_can_fast_intersect is wrong for the non-anchored case, returning self.freq.n == 1
which is not sufficient in this case. It may be that we just need to return False for non-anchored.
Expected Behavior
The intersection should be empty