Skip to content

Commit 248830b

Browse files
committed
DOC: sub-section on boolean Index array changes
closes pandas-dev#17740
1 parent 5653fe4 commit 248830b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

doc/source/whatsnew/v0.21.0.txt

+31
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,37 @@ Selection with all keys found is unchanged.
356356

357357
s.loc[[1, 2]]
358358

359+
.. _whatsnew_0210.api_breaking.loc_with_index:
360+
361+
Indexing with a Boolean Index
362+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
363+
364+
Previously when passing a boolean ``Index`` to ``.loc``, if the index of the ``Series/DataFrame`` had ``boolean`` labels,
365+
you would get a label based selection, potentially duplicating result labels, rather than a boolean indexing selection
366+
(where ``True`` selects elements), this was inconsistent how a boolean numpy array indexed. The new behavior is to
367+
act like a boolean numpy array indexer. (:issue:`17738`)
368+
369+
Previous Behavior:
370+
371+
.. ipython:: python
372+
373+
s = pd.Series([1, 2, 3], index=[False, True, False])
374+
375+
.. code-block:: ipython
376+
377+
In [59]: s.loc[pd.Index([True, False, True])]
378+
Out[59]:
379+
True 2
380+
False 1
381+
False 3
382+
True 2
383+
dtype: int64
384+
385+
Current Behavior
386+
387+
.. ipython:: python
388+
389+
s.loc[pd.Index([True, False, True])]
359390

360391
.. _whatsnew_0210.api_breaking.pandas_eval:
361392

0 commit comments

Comments
 (0)