Skip to content

Commit a0c8425

Browse files
Added alignable boolean series and its example to .loc docs. (#35506)
1 parent 017bde1 commit a0c8425

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/core/indexing.py

+11
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. The 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 frame index.
267271
268272
See Also
269273
--------
@@ -319,6 +323,13 @@ 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],
329+
... index=['viper', 'sidewinder', 'cobra'])]
330+
max_speed shield
331+
sidewinder 7 8
332+
322333
Conditional that returns a boolean Series
323334
324335
>>> df.loc[df['shield'] > 6]

0 commit comments

Comments
 (0)