You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "report.py", line 10, in <module>
index.drop(index[0])
File ".venv/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 6930, in drop
indexer =self.get_indexer_for(labels)
File "/.venv/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 6052, in get_indexer_forreturnself.get_indexer(target)
File ".venv/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3973, in get_indexerreturnself._get_indexer(target, method, limit, tolerance)
File ".venv/lib/python3.10/site-packages/pandas/core/indexes/interval.py", line 685, in _get_indexer
indexer =self._get_indexer_unique_sides(target)
File ".venv/lib/python3.10/site-packages/pandas/core/indexes/interval.py", line 738, in _get_indexer_unique_sides
right_indexer =self.right.get_indexer(target.right)
File ".venv/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3904, in get_indexerraise InvalidIndexError(self._requires_unique_msg)
pandas.errors.InvalidIndexError: Reindexing only valid with uniquely valued Index objects
Issue Description
Dropping an element from an IntervalIndex containing zero-length intervals raises an InvalidIndexError claiming Reindexing only valid with uniquely valued Index objects. Yet, index.is_unique returns true.
This sees to be related to #49581 . This is different from #38051 because it does not contain duplicates.
Expected Behavior
The first element of the index should be dropped without complaining.
Alternatively update the documentation to say when and why errors can be expected and what exactly happens if errors=ignore is supplied. Also reference that option in the InvalidIndexError message.
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
Dropping an element from an
IntervalIndex
containing zero-length intervals raises anInvalidIndexError
claimingReindexing only valid with uniquely valued Index objects
. Yet,index.is_unique
returnstrue
.This sees to be related to #49581 . This is different from #38051 because it does not contain duplicates.
Expected Behavior
The first element of the index should be dropped without complaining.
Alternatively update the documentation to say when and why errors can be expected and what exactly happens if
errors=ignore
is supplied. Also reference that option in theInvalidIndexError
message.Installed Versions
The text was updated successfully, but these errors were encountered: