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

Int Index.slice_locs Not Raising with Float Arguments #20915

Closed
WillAyd opened this issue May 1, 2018 · 1 comment · Fixed by #25277
Closed

Int Index.slice_locs Not Raising with Float Arguments #20915

WillAyd opened this issue May 1, 2018 · 1 comment · Fixed by #25277
Labels
Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@WillAyd
Copy link
Member

WillAyd commented May 1, 2018

xref #4892 as I'm going through #20812 I am seeing tests which suggest that trying to call slice_locs with float arguments against an integer type Index should raise a TypeError:

pytest.raises(TypeError,

While these tests are currently passing, I believe the TypeError is getting raised from the call to pytest.raises (specifically a 'list' object is not callable for the third argument to pytest.raises) and not as a result of the actual index.slice_locs call.

>>> pd.__version__
'0.23.0.dev0+824.gc4da79b5b.dirty'
>>> index = pd.Index(np.array([0, 1, 2, 5, 6, 7, 9, 10], dtype=int))
>>> index.slice_locs(5.0, 10.0)
(3, 8)
>>> index.slice_locs(4.5, 10.5)
(3, 8)
@WillAyd WillAyd changed the title Index.slice_locs not raising with float arguments Int Index.slice_locs Not Raising with Float Arguments May 1, 2018
@gfyoung gfyoung added Indexing Related to indexing on series/frames, not to indexes themselves Dtype Conversions Unexpected or buggy dtype conversions labels May 8, 2018
@simonjayhawkins
Copy link
Member

the TypeError message was added in #4850

https://github.com/jreback/pandas/blob/60efe85bc2ce9578e8f5e0c88907c5cc6b6b7b31/pandas/core/index.py#L526-L531

and has since been removed. int slicing with floats is now allowed.

@jreback jreback added this to the 0.25.0 milestone Feb 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants