Skip to content

Commit

Permalink
#31054 Added alignable boolean series and its example to .loc docs.
Browse files Browse the repository at this point in the history
Fixed formatting
  • Loading branch information
MJafarMashhadi committed Aug 1, 2020
1 parent 017bde1 commit 4014a60
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ def loc(self) -> "_LocIndexer":
- A boolean array of the same length as the axis being sliced,
e.g. ``[True, False, True]``.
- An alignable boolean series. Index of the key will be aligned before
masking.
- A ``callable`` function with one argument (the calling Series or
DataFrame) and that returns valid output for indexing (one of the above)
Expand All @@ -264,6 +266,8 @@ def loc(self) -> "_LocIndexer":
------
KeyError
If any items are not found.
IndexingError
If an indexed key is passed and its index is unalignable to the index.
See Also
--------
Expand Down Expand Up @@ -319,6 +323,13 @@ def loc(self) -> "_LocIndexer":
max_speed shield
sidewinder 7 8
Alignable boolean series:
>>> df.loc[pd.Series([False, True, False],
... index=['viper', 'sidewinder', 'cobra'])]
max_speed shield
sidewinder 7 8
Conditional that returns a boolean Series
>>> df.loc[df['shield'] > 6]
Expand Down

0 comments on commit 4014a60

Please sign in to comment.