From 2de41b381da0ddd0da0b57ee7612d9867dfa7139 Mon Sep 17 00:00:00 2001 From: Robert Tidball <57079898+roberttidball@users.noreply.github.com> Date: Sat, 13 Sep 2025 14:53:45 +1000 Subject: [PATCH 1/2] 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. --- doc/source/user_guide/cookbook.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/source/user_guide/cookbook.rst b/doc/source/user_guide/cookbook.rst index 91a0b4a4fe967..2df471223c3d2 100644 --- a/doc/source/user_guide/cookbook.rst +++ b/doc/source/user_guide/cookbook.rst @@ -239,6 +239,14 @@ Ambiguity arises when an index consists of integers with a non-zero start or non df[~((df.AAA <= 6) & (df.index.isin([0, 2, 4])))] +Using isin() to filter for values directly (this returns a series of boolean values). + +.. ipython:: python + df = pd.DataFrame( + {"AAA": [4, 5, 6, 7], "BBB": [10, 20, 30, 40], "CCC": [100, 50, -30, -50]} + ) + df["AAA"].isin([5, 7]) + New columns *********** From e3d1bc6e3463375f77a53f5ef1ec2617d8a94171 Mon Sep 17 00:00:00 2001 From: Robert Tidball <57079898+roberttidball@users.noreply.github.com> Date: Sat, 13 Sep 2025 16:18:44 +1000 Subject: [PATCH 2/2] Error in ipython syntax --- doc/source/user_guide/cookbook.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/user_guide/cookbook.rst b/doc/source/user_guide/cookbook.rst index 2df471223c3d2..7418c628b9fee 100644 --- a/doc/source/user_guide/cookbook.rst +++ b/doc/source/user_guide/cookbook.rst @@ -242,6 +242,7 @@ Ambiguity arises when an index consists of integers with a non-zero start or non Using isin() to filter for values directly (this returns a series of boolean values). .. ipython:: python + df = pd.DataFrame( {"AAA": [4, 5, 6, 7], "BBB": [10, 20, 30, 40], "CCC": [100, 50, -30, -50]} )