BUG/inconsistency: IntervalIndex.get_loc gives a location for non-exact inputs #19349
Labels
API Design
Bug
Indexing
Related to indexing on series/frames, not to indexes themselves
Interval
Interval data type
This one is a bit complex to explain, but I'll do my best.
Currently
IntervalIndex.get_indexer
fails if the other index doesn't containInterval
only (there's also another bug, but let's keep it simple here).The underlying issue is that
IntervalIndex.get_indexer
depends onIntervalIndex.get_loc
which is ambigous for how it treats number inputs:The issue is that
get_loc
returns the location for both exact matches and inexact matches (i.e. if the number input is in an interval). For the purposes ofget_indexer
however, this behavious fails, asget_indexer
needsget_loc
to find exact matches only.See #19021 (comment) for further discussion.
Solution
A solution could be adding a
'strict'
option to themethod
parameter ofIntervalIndex.get_loc
.This wasn't so difficult after all, and I've already made a PR on this, see #19353
The text was updated successfully, but these errors were encountered: