You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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."
The text was updated successfully, but these errors were encountered:
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
Pandas version checks
main
hereLocation 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."
The text was updated successfully, but these errors were encountered: