Skip to content
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

Index.slice_locs Missing Argument Only Raises with NA Data #20917

Open
WillAyd opened this issue May 1, 2018 · 1 comment
Open

Index.slice_locs Missing Argument Only Raises with NA Data #20917

WillAyd opened this issue May 1, 2018 · 1 comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Needs Discussion Requires discussion from core team before further action

Comments

@WillAyd
Copy link
Member

WillAyd commented May 1, 2018

xref #20915 perhaps another issue here - I can't tell if this is by design or not:

>>> pd.__version__
'0.23.0.dev0+824.gc4da79b5b.dirty'

>>> index = pd.Index([1., 2.])
>>> index.slice_locs(1.5)
(1, 2)

>>> index = pd.Index([1., 2., np.nan])
>>> index.slice_locs(1.5)
pandas._libs.hashtable.Float64HashTable.get_item
    raise KeyError(val)
KeyError: 1.5
@gfyoung gfyoung added the Indexing Related to indexing on series/frames, not to indexes themselves label May 8, 2018
@toobaz toobaz added Index Related to the Index class or subclasses and removed Indexing Related to indexing on series/frames, not to indexes themselves labels Jun 29, 2019
@jbrockmendel jbrockmendel added Indexing Related to indexing on series/frames, not to indexes themselves and removed Index Related to the Index class or subclasses labels Feb 22, 2020
@phofl
Copy link
Member

phofl commented Nov 10, 2020

cc @WillAyd The raise in the second seems to be ok, but missleading error message I think? slice_locs only works when Index is monotonic, not the case with nan.

But I could not find any information if this should raise in general when Key is not present in Index?

@mroeschke mroeschke added Bug Needs Discussion Requires discussion from core team before further action labels Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Needs Discussion Requires discussion from core team before further action
Projects
None yet
Development

No branches or pull requests

6 participants