BUG: DatetimeIndex.intersection with non-anchored freq · Issue #44025 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@jbrockmendel

Description

@jbrockmendel

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