Skip to content

DOC: iloc boolean indexing potential wording error #47224

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

Open
1 task done
rhug123 opened this issue Jun 4, 2022 · 2 comments
Open
1 task done

DOC: iloc boolean indexing potential wording error #47224

rhug123 opened this issue Jun 4, 2022 · 2 comments
Assignees
Labels
Docs Indexing Related to indexing on series/frames, not to indexes themselves

Comments

@rhug123
Copy link

rhug123 commented Jun 4, 2022

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/user_guide/indexing.html#boolean-indexing

Documentation problem

The documentation states under boolean indexing (indexing and selecting data):

"iloc supports two kinds of boolean indexing. If the indexer is a boolean Series, an error will be raised. For instance, in the following example, df.iloc[s.values, 1] is ok. The boolean indexer is an array. But df.iloc[s, 1] would raise ValueError."

The issue is with the first sentence stating that iloc supports two kinds of boolean indexing. .iloc however does not support indexing with a boolean series (only .loc does).

Suggested fix for documentation

I believe the current documentation should be replaced with the below change.

".iloc only supports one kind of boolean indexing. If the indexer is a boolean Series, an error will be raised. For instance, in the following example, df.iloc[s.values, 1] is ok. The boolean indexer is an array. But df.iloc[s, 1] would raise ValueError."

If you agree with this change, perhaps it would also be beneficial to highlight differences between loc and iloc when it comes to boolean indexing such as:

"While .loc supports two kinds of boolean indexing, .iloc only supports indexing with a boolean array. If the indexer is a boolean Series, an error will be raised. For instance, in the following example, df.iloc[s.values, 1] is ok. The boolean indexer is an array. But df.iloc[s, 1] would raise ValueError."

@rhug123 rhug123 added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 4, 2022
@rhug123
Copy link
Author

rhug123 commented Jun 8, 2022

take

@rhug123 rhug123 removed their assignment Jul 9, 2022
@mroeschke mroeschke added Indexing Related to indexing on series/frames, not to indexes themselves and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 16, 2024
@bluestarunderscore
Copy link
Contributor

take

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

No branches or pull requests

3 participants