Skip to content

Commit 5782dc0

Browse files
authored
DOC: Distinguish between different types of boolean indexing #10492 (#36869)
1 parent ea98a29 commit 5782dc0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

doc/source/user_guide/indexing.rst

+18
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,24 @@ and :ref:`Advanced Indexing <advanced>` you may select along more than one axis
933933
934934
df2.loc[criterion & (df2['b'] == 'x'), 'b':'c']
935935
936+
.. warning::
937+
938+
``iloc`` supports two kinds of boolean indexing. If the indexer is a boolean ``Series``,
939+
an error will be raised. For instance, in the following example, ``df.iloc[s.values, 1]`` is ok.
940+
The boolean indexer is an array. But ``df.iloc[s, 1]`` would raise ``ValueError``.
941+
942+
.. ipython:: python
943+
944+
df = pd.DataFrame([[1, 2], [3, 4], [5, 6]],
945+
index=list('abc'),
946+
columns=['A', 'B'])
947+
s = (df['A'] > 2)
948+
s
949+
950+
df.loc[s, 'B']
951+
952+
df.iloc[s.values, 1]
953+
936954
.. _indexing.basics.indexing_isin:
937955

938956
Indexing with isin

0 commit comments

Comments
 (0)