-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DOC: Index.get_loc Cannot Accept List-like Tolerance #20930
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
Comments
is this just a doc issue? the above looks correct |
If the above is all correct then yes it is a doc issue. Below is taken directly from the API docs: "Tolerance may be a scalar value, which applies the same tolerance to all values, or list-like, which applies variable tolerance per element..." |
yeah above is correct |
I think that limitation only applies when doing anything but an exact match. >>> index = pd.Index([1, 1, 1])
>>> index.get_loc(1)
slice(0, 3, None)
>>> index.get_loc(1, method='pad')
pandas.core.indexes.base.InvalidIndexError: Reindexing only valid with uniquely valued Index objects The docs even provide an example of this. Regardless good opportunity for cleanup here |
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: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 forget_loc
should be updated to reflect what can actually be acceptedThe text was updated successfully, but these errors were encountered: