From 94095c79c8c36e483756328ff7fc5f4a8872c3e6 Mon Sep 17 00:00:00 2001 From: Omar Afifi Date: Sat, 9 Jan 2021 20:31:35 +0200 Subject: [PATCH 1/5] Added docs for the change of behavior of isin This is to close issue #38781 --- pandas/core/series.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pandas/core/series.py b/pandas/core/series.py index 668cad4f64ac3..348d2d92f8e26 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4630,6 +4630,34 @@ def isin(self, values) -> "Series": 4 True 5 False Name: animal, dtype: bool + + New behaviour from pandas v1.2.0 caused some tests to fail because users where unaware of this change. + + Before v1.2.0: + + >>>import pandas as pd + pd.Series([0]).isin(['0']) + # 0 True + # dtype: bool + pd.Series([1]).isin(['1']) + # 0 True + # dtype: bool + pd.Series([1.1]).isin(['1.1']) + # 0 True + # dtype: bool + + From v1.2.0 + + >>>import pandas as pd + pd.Series([0]).isin(['0']) + # 0 False + # dtype: bool + pd.Series([1]).isin(['1']) + # 0 False + # dtype: bool + pd.Series([1.1]).isin(['1.1']) + # 0 False + # dtype: bool """ result = algorithms.isin(self._values, values) return self._constructor(result, index=self.index).__finalize__( From 7d36f0f75be02d8c768b331ffe397645556b30ab Mon Sep 17 00:00:00 2001 From: Omar Afifi Date: Sun, 10 Jan 2021 19:00:09 +0200 Subject: [PATCH 2/5] updated docs for isin --- pandas/core/series.py | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 348d2d92f8e26..522b698b74124 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4631,33 +4631,16 @@ def isin(self, values) -> "Series": 5 False Name: animal, dtype: bool - New behaviour from pandas v1.2.0 caused some tests to fail because users where unaware of this change. - - Before v1.2.0: - - >>>import pandas as pd - pd.Series([0]).isin(['0']) - # 0 True - # dtype: bool - pd.Series([1]).isin(['1']) - # 0 True - # dtype: bool - pd.Series([1.1]).isin(['1.1']) - # 0 True - # dtype: bool - - From v1.2.0 + .. versionchanged:: 1.2.0 + Strings and integers are now treated as distinct. This new behaviour caused some tests to fail because users where unaware of this change. >>>import pandas as pd - pd.Series([0]).isin(['0']) - # 0 False - # dtype: bool pd.Series([1]).isin(['1']) - # 0 False - # dtype: bool + 0 False + dtype: bool pd.Series([1.1]).isin(['1.1']) - # 0 False - # dtype: bool + 0 False + dtype: bool """ result = algorithms.isin(self._values, values) return self._constructor(result, index=self.index).__finalize__( From cd13e577c56ed0db59a589315c34d892b4c5de03 Mon Sep 17 00:00:00 2001 From: Omar Afifi Date: Thu, 14 Jan 2021 20:11:14 +0200 Subject: [PATCH 3/5] update docs for isin --- pandas/core/series.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 522b698b74124..11fe01690e5ae 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4631,8 +4631,7 @@ def isin(self, values) -> "Series": 5 False Name: animal, dtype: bool - .. versionchanged:: 1.2.0 - Strings and integers are now treated as distinct. This new behaviour caused some tests to fail because users where unaware of this change. + Strings and integers are distinct and are therefore not comparable: >>>import pandas as pd pd.Series([1]).isin(['1']) From 86f0e86e30b28d2557f2a2a79acfc134e619c116 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Sat, 16 Jan 2021 13:01:41 +0000 Subject: [PATCH 4/5] lint --- pandas/core/series.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 11fe01690e5ae..fa031a864dd72 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4630,14 +4630,14 @@ def isin(self, values) -> "Series": 4 True 5 False Name: animal, dtype: bool - + Strings and integers are distinct and are therefore not comparable: - + >>>import pandas as pd - pd.Series([1]).isin(['1']) + pd.Series([1]).isin(['1']) 0 False dtype: bool - pd.Series([1.1]).isin(['1.1']) + pd.Series([1.1]).isin(['1.1']) 0 False dtype: bool """ From 22fe1ffca55355db227e3530d5c1fb862bef44fc Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Sat, 16 Jan 2021 13:11:42 +0000 Subject: [PATCH 5/5] doctest fix --- pandas/core/series.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 89bd712876ff8..3888194305d76 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4602,11 +4602,10 @@ def isin(self, values) -> Series: Strings and integers are distinct and are therefore not comparable: - >>>import pandas as pd - pd.Series([1]).isin(['1']) + >>> pd.Series([1]).isin(['1']) 0 False dtype: bool - pd.Series([1.1]).isin(['1.1']) + >>> pd.Series([1.1]).isin(['1.1']) 0 False dtype: bool """