Skip to content

Commit 0511d75

Browse files
pandas-dev#31054 Added alignable boolean series and its example to .loc docs.
1 parent bdcc5bf commit 0511d75

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/core/indexing.py

+10
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ def loc(self) -> "_LocIndexer":
255255
256256
- A boolean array of the same length as the axis being sliced,
257257
e.g. ``[True, False, True]``.
258+
- An alignable boolean series. Index of the key will be aligned before
259+
masking.
258260
- A ``callable`` function with one argument (the calling Series or
259261
DataFrame) and that returns valid output for indexing (one of the above)
260262
@@ -264,6 +266,8 @@ def loc(self) -> "_LocIndexer":
264266
------
265267
KeyError
266268
If any items are not found.
269+
IndexingError
270+
If an indexed key is passed and its index is unalignable to the index.
267271
268272
See Also
269273
--------
@@ -319,6 +323,12 @@ def loc(self) -> "_LocIndexer":
319323
max_speed shield
320324
sidewinder 7 8
321325
326+
Alignable boolean series:
327+
328+
>>> df.loc[pd.Series([False, True, False], index=['viper', 'sidewinder', 'cobra'])]
329+
max_speed shield
330+
sidewinder 7 8
331+
322332
Conditional that returns a boolean Series
323333
324334
>>> df.loc[df['shield'] > 6]

0 commit comments

Comments
 (0)