Skip to content

Commit 2de41b3

Browse files
Added note on isin() to cookbook
The cookbook examples contained isin() within the context of choosing indexes, I have included an example for filtering values directly.
1 parent cc40732 commit 2de41b3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

doc/source/user_guide/cookbook.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ Ambiguity arises when an index consists of integers with a non-zero start or non
239239
240240
df[~((df.AAA <= 6) & (df.index.isin([0, 2, 4])))]
241241
242+
Using isin() to filter for values directly (this returns a series of boolean values).
243+
244+
.. ipython:: python
245+
df = pd.DataFrame(
246+
{"AAA": [4, 5, 6, 7], "BBB": [10, 20, 30, 40], "CCC": [100, 50, -30, -50]}
247+
)
248+
df["AAA"].isin([5, 7])
249+
242250
New columns
243251
***********
244252

0 commit comments

Comments
 (0)