Skip to content

PERF: IntervalIndex.isin #38353

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

Merged
merged 12 commits into from
Dec 14, 2020
Merged

PERF: IntervalIndex.isin #38353

merged 12 commits into from
Dec 14, 2020

Conversation

jbrockmendel
Copy link
Member

In [1]: import pandas as pd

In [2]: ii = pd.IntervalIndex.from_breaks(range(100000))

In [3]: values = ii[:100]

In [4]: from pandas.core.algorithms import isin

In [5]: %timeit isin(ii, values)
91.3 ms ± 5.24 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)  # <-- master
3.84 ms ± 57.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)  # <-- PR

@jreback jreback added Interval Interval data type Performance Memory or execution speed performance labels Dec 8, 2020
@jreback jreback added this to the 1.3 milestone Dec 8, 2020
@@ -1435,6 +1438,40 @@ def contains(self, other):
other < self._right if self.open_right else other <= self._right
)

def isin(self, values) -> np.ndarray:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally type values here, though i guess this is public so might be tricky)

@jreback
Copy link
Contributor

jreback commented Dec 13, 2020

ok this is fine. can you add a whatsnew note. ping on green.

@jbrockmendel
Copy link
Member Author

ping

@jreback jreback merged commit 2b51abe into pandas-dev:master Dec 14, 2020
@jbrockmendel jbrockmendel deleted the enh-isin branch December 14, 2020 15:52
luckyvs1 pushed a commit to luckyvs1/pandas that referenced this pull request Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Interval Interval data type Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants