-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
[PERF] Get rid of MultiIndex conversion in IntervalIndex.is_unique #26391
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
Changes from all commits
4ec1fe9
51d6910
d11acd6
202b2cf
8e8384b
8dde393
d3af9c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -461,7 +461,24 @@ def is_unique(self): | |
""" | ||
Return True if the IntervalIndex contains unique elements, else False | ||
""" | ||
return self._multiindex.is_unique | ||
left = self.left | ||
right = self.right | ||
|
||
if self.isna().sum() > 1: | ||
return False | ||
|
||
if left.is_unique or right.is_unique: | ||
return True | ||
|
||
seen_pairs = set() | ||
check_idx = np.where(left.duplicated(keep=False))[0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. acutally can't you just do this
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The present approach may be better in which |
||
for idx in check_idx: | ||
pair = (left[idx], right[idx]) | ||
if pair in seen_pairs: | ||
return False | ||
seen_pairs.add(pair) | ||
|
||
return True | ||
|
||
@cache_readonly | ||
@Appender(_interval_shared_docs['is_non_overlapping_monotonic'] | ||
|
Uh oh!
There was an error while loading. Please reload this page.