@@ -356,6 +356,61 @@ 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+ s
375+
376+ .. code-block:: ipython
377+
378+ In [59]: s.loc[pd.Index([True, False, True])]
379+ Out[59]:
380+ True 2
381+ False 1
382+ False 3
383+ True 2
384+ dtype: int64
385+
386+ Current Behavior
387+
388+ .. ipython:: python
389+
390+ s.loc[pd.Index([True, False, True])]
391+
392+
393+ Furthermore, previously if you had an index that was non-numeric (e.g. strings), then a boolean Index would raise a ``KeyError``.
394+ This will now be treated as a boolean indexer.
395+
396+ Previously Behavior:
397+
398+ .. ipython:: python
399+
400+ s = pd.Series([1,2,3], index=['a', 'b', 'c'])
401+ s
402+
403+ .. code-block:: ipython
404+
405+ In [39]: s.loc[pd.Index([True, False, True])]
406+ KeyError: "None of [Index([True, False, True], dtype='object')] are in the [index]"
407+
408+ Current Behavior
409+
410+ .. ipython:: python
411+
412+ s.loc[pd.Index([True, False, True])]
413+
359414
360415.. _whatsnew_0210.api_breaking.pandas_eval:
361416
0 commit comments