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

Deprecate DataFrame indexer for iloc setitem and getitem #39022

Merged
merged 14 commits into from
Mar 2, 2021

Conversation

phofl
Copy link
Member

@phofl phofl commented Jan 7, 2021

@phofl phofl added Error Reporting Incorrect or improved errors from pandas Indexing Related to indexing on series/frames, not to indexes themselves labels Jan 7, 2021
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my note on the PR: #39004 (comment)

In addition, if we disallow this, I think it should be deprecated first for assignment (since that case was working right now)

@jreback
Copy link
Contributor

jreback commented Jan 8, 2021

See my note on the PR: #39004 (comment)

In addition, if we disallow this, I think it should be deprecated first for assignment (since that case was working right now)

this is reasonable to deprecate for setitem and simply raise for getitem. @phofl if you can amend.

though I am tempted to simply call this a bug fix if setitem actually gives wrong behavior? (or is it actually somewhat correct?)

@phofl
Copy link
Member Author

phofl commented Jan 8, 2021

Don't know if I would call this wrong. It is counterintuitive for sure.

If you know that iloc does not align, you may expect the result, Additionally it only works if indexer has the same dimension as the object to index.

Will add a DeprecationWarning

@jreback
Copy link
Contributor

jreback commented Jan 8, 2021

Will add a DeprecationWarning

FutureWarning but thanks

@phofl
Copy link
Member Author

phofl commented Jan 8, 2021

Added the Warning

pandas/core/indexing.py Outdated Show resolved Hide resolved
@phofl phofl changed the title Disallow DataFrame indexer for iloc setitem and getitem Deprecate DataFrame indexer for iloc setitem and getitem Jan 8, 2021
Co-authored-by: Jeff Reback <jeff@reback.net>
@pep8speaks
Copy link

pep8speaks commented Jan 8, 2021

Hello @phofl! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-03-02 19:53:34 UTC

pandas/core/indexing.py Outdated Show resolved Hide resolved
phofl and others added 3 commits January 8, 2021 18:42
@phofl
Copy link
Member Author

phofl commented Jan 8, 2021

Added a deprecation whatsnew

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm tiny comment

"DataFrame indexer for .iloc is deprecated and will be removed in"
"a future version.\n"
"consider using .loc with a DataFrame indexer for automatic alignment."
"a future version",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repeated 'a future version'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, changed

@phofl
Copy link
Member Author

phofl commented Jan 8, 2021

@jreback green

@jorisvandenbossche
Copy link
Member

Let's give this a bit more time, since the discussion in #39004 is still ongoing

� Conflicts:
�	doc/source/whatsnew/v1.3.0.rst
� Conflicts:
�	doc/source/whatsnew/v1.3.0.rst
@jreback
Copy link
Contributor

jreback commented Jan 20, 2021

@phofl conflict and if you can rebase. i think this is fine to merge.

� Conflicts:
�	doc/source/whatsnew/v1.3.0.rst
@phofl
Copy link
Member Author

phofl commented Jan 20, 2021

Done, failure unrelated

@jreback
Copy link
Contributor

jreback commented Jan 21, 2021

this looks fine to me. @jorisvandenbossche are you still objecting?

@jreback
Copy link
Contributor

jreback commented Feb 11, 2021

@phofl can you merge master and update

@phofl
Copy link
Member Author

phofl commented Feb 13, 2021

@jreback merged master, failure unrelated

@gooney47 gooney47 mentioned this pull request Feb 15, 2021
4 tasks
@jreback
Copy link
Contributor

jreback commented Feb 15, 2021

everyone ok here ?

@jorisvandenbossche @phofl @jbrockmendel @gooney47

@jbrockmendel
Copy link
Member

LGTM

� Conflicts:
�	pandas/tests/indexing/test_iloc.py
@phofl
Copy link
Member Author

phofl commented Mar 2, 2021

Are we good here?

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. ping on greenish

@phofl
Copy link
Member Author

phofl commented Mar 2, 2021

@jreback greenish

@jreback jreback merged commit dd2e721 into pandas-dev:master Mar 2, 2021
@jreback
Copy link
Contributor

jreback commented Mar 2, 2021

thanks @phofl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: IndexError: positional indexers are out-of-bounds iloc boolean indexing
5 participants