Skip to content

iloc errors when end is greater than length #6296

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

Closed
jseabold opened this issue Feb 7, 2014 · 4 comments · Fixed by #6299
Closed

iloc errors when end is greater than length #6296

jseabold opened this issue Feb 7, 2014 · 4 comments · Fixed by #6299
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@jseabold
Copy link
Contributor

jseabold commented Feb 7, 2014

IMO this should work

x = pd.DataFrame(np.random.rand(5,3))
x.iloc[:6]

Consider

np.arange(5)[:7]

And

range(5)[:7]

I'm on

[~/]
[14]: pd.version.version
[14]: '0.13.1-63-gcc6ee40'
@jreback
Copy link
Contributor

jreback commented Feb 7, 2014

see very end of the section: http://pandas-docs.github.io/pandas-docs-travis/indexing.html#selection-by-position

I believe this originally (with iget/icol) was done on purpose. e.g. let the user know.

you are advocating to allow it?

FYI, you can use head/tail to avoid this problem as they won't run off the end

@jseabold
Copy link
Contributor Author

jseabold commented Feb 7, 2014

Yeah I'm trimming based on something else that's not a pandas object (because rolling_apply, etc. work with arrays only for now as remarked elsewhere), so I have something like

x.iloc[:len(y)]

I worry about alignment later. I just expected it to work since it's common that it works elsewhere in numpython. E.g.,

range(5)[7:9]

User's problem to check for emptiness.

@jreback
Copy link
Contributor

jreback commented Feb 7, 2014

ok. easy enough to do....I think that's fine

@jreback
Copy link
Contributor

jreback commented Feb 7, 2014

@jseabold this actually helped with another issue on multi-indexing...(with unbalanced levels)....

anyhow...take a look at #6299....see if that looks reasonable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants