Closed
Description
The docs for Index.get_loc
suggest that the tolerance parameter may accept both a scalar and list-like argument. However, I don't think this is actually possible:
# Can only pass scalar label to unique Index, so tolerance cannot be list-like
>>> pd.Index([0, 1, 2]).get_loc(1)
1
>>> pd.Index([0, 1, 2]).get_loc([1, 1])
TypeError: '[1, 1]' is an invalid key
# Inexact matches do not work against non-unique index
>>> pd.Index([1, 1, 2]).get_loc(1.1, method='nearest')
pandas.core.indexes.base.InvalidIndexError: Reindexing only valid with uniquely valued Index objects
In short I don't think this method can ever return a list using inexact matches. IIUC the documented list-like tolerance
argument is therefore invalid.
I don't see any tests for this behavior and my assumption is it was documented as part of this methods overlap with get_indexer
, but the documentation for get_loc
should be updated to reflect what can actually be accepted