Skip to content

BUG: DatetimeIndex.intersection with non-anchored freq #44025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jbrockmendel opened this issue Oct 14, 2021 · 1 comment
Open

BUG: DatetimeIndex.intersection with non-anchored freq #44025

jbrockmendel opened this issue Oct 14, 2021 · 1 comment
Labels
Bug Frequency DateOffsets Index Related to the Index class or subclasses setops union, intersection, difference, symmetric_difference

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Oct 14, 2021

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

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member Frequency DateOffsets Index Related to the Index class or subclasses and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 14, 2021
@jbrockmendel
Copy link
Member Author

Hmm actually CDay is considered anchored, but that doesn't appear to be all that meaningful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Frequency DateOffsets Index Related to the Index class or subclasses setops union, intersection, difference, symmetric_difference
Projects
None yet
Development

No branches or pull requests

2 participants