Skip to content

BUG: IntervalIndex.unique() only contains the first interval if all interval borders are negative #61920

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
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

khemkaran10
Copy link
Contributor

Fixes: #61917
Before FIx ❌:

idx_neg = pd.IntervalIndex.from_tuples([(-4, -3), (-4, -3), (-3, -2), (-3, -2), (-2, -1), (-2, -1)])
print(idx_neg.unique())

# Output:
# IntervalIndex([(-4, -3]], dtype='interval[int64, right]')

After Fix ✅:

idx_neg = pd.IntervalIndex.from_tuples([(-4, -3), (-4, -3), (-3, -2), (-3, -2), (-2, -1), (-2, -1)])
print(idx_neg.unique())

# output:
# IntervalIndex([(-4, -3], (-3, -2], (-2, -1]], dtype='interval[int64, right]')

@simonjayhawkins simonjayhawkins added Bug Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Interval Interval data type labels Jul 22, 2025
@simonjayhawkins simonjayhawkins changed the title FIX BUG: IntervalIndex.unique() only contains the first interval if all interval borders are negative BUG: IntervalIndex.unique() only contains the first interval if all interval borders are negative Jul 22, 2025
nc = unique(
self._combined.view("complex128")[:, 0] # type: ignore[call-overload]
)
if needs_i8_conversion(self._left.dtype):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I kept this is because this test was failing with the new approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Bug Interval Interval data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: IntervalIndex.unique() only contains the first interval if all interval borders are negative
4 participants