From 735f1b7408778d9b9bee202e1a5a60640d8afc36 Mon Sep 17 00:00:00 2001 From: DaanVanHauwermeiren Date: Sat, 10 Mar 2018 16:06:02 +0100 Subject: [PATCH 1/7] update docstring series.isin --- pandas/core/series.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 069f0372ab6e1..4ea3879c52613 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2745,9 +2745,8 @@ def _take(self, indices, axis=0, convert=True, is_copy=False): def isin(self, values): """ - Return a boolean :class:`~pandas.Series` showing whether each element - in the :class:`~pandas.Series` is exactly contained in the passed - sequence of ``values``. + Return a boolean ``Series`` showing whether each element in the + ``Series`` is exactly contained in the passed sequence of ``values``. Parameters ---------- @@ -2758,7 +2757,7 @@ def isin(self, values): .. versionadded:: 0.18.1 - Support for values as a set + Support for values as a set. Returns ------- @@ -2771,7 +2770,7 @@ def isin(self, values): See Also -------- - pandas.DataFrame.isin + pandas.DataFrame.isin : equivalent method on DataFrame Examples -------- @@ -2791,7 +2790,6 @@ def isin(self, values): 1 False 2 False dtype: bool - """ result = algorithms.isin(com._values_from_object(self), values) return self._constructor(result, index=self.index).__finalize__(self) From 293cbc990ac90a89c085e0206f0661d802bb990d Mon Sep 17 00:00:00 2001 From: DaanVanHauwermeiren Date: Sat, 10 Mar 2018 16:13:07 +0100 Subject: [PATCH 2/7] add short summary --- pandas/core/series.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/core/series.py b/pandas/core/series.py index 4ea3879c52613..48a36992b94b2 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2745,6 +2745,8 @@ def _take(self, indices, axis=0, convert=True, is_copy=False): def isin(self, values): """ + Check whether ``values`` are contained in ``Series``. + Return a boolean ``Series`` showing whether each element in the ``Series`` is exactly contained in the passed sequence of ``values``. From ea48bf0e3c9ae18d11823d034cb208c5b0355de5 Mon Sep 17 00:00:00 2001 From: DaanVanHauwermeiren Date: Sat, 10 Mar 2018 16:13:50 +0100 Subject: [PATCH 3/7] update example to animal-framework --- pandas/core/series.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 48a36992b94b2..16915d5121bab 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2777,21 +2777,28 @@ def isin(self, values): Examples -------- - >>> s = pd.Series(list('abc')) - >>> s.isin(['a', 'c', 'e']) + >>> s = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama', + ... 'hippo'], name='animal') + >>> s.isin(['cow', 'lama']) 0 True - 1 False + 1 True 2 True - dtype: bool + 3 False + 4 True + 5 False + Name: animal, dtype: bool - Passing a single string as ``s.isin('a')`` will raise an error. Use + Passing a single string as ``s.isin('lama')`` will raise an error. Use a list of one element instead: - >>> s.isin(['a']) + >>> s.isin(['lama']) 0 True 1 False - 2 False - dtype: bool + 2 True + 3 False + 4 True + 5 False + Name: animal, dtype: bool """ result = algorithms.isin(com._values_from_object(self), values) return self._constructor(result, index=self.index).__finalize__(self) From 6fa3bc9edcdbe32b169c3364b125c9e35e8f4997 Mon Sep 17 00:00:00 2001 From: DaanVanHauwermeiren Date: Sat, 10 Mar 2018 16:22:36 +0100 Subject: [PATCH 4/7] remove redundant double quotations around Series --- pandas/core/series.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 16915d5121bab..c3f975e0eafbd 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2745,10 +2745,10 @@ def _take(self, indices, axis=0, convert=True, is_copy=False): def isin(self, values): """ - Check whether ``values`` are contained in ``Series``. + Check whether ``values`` are contained in Series. - Return a boolean ``Series`` showing whether each element in the - ``Series`` is exactly contained in the passed sequence of ``values``. + Return a boolean Series showing whether each element in the Series + is exactly contained in the passed sequence of ``values``. Parameters ---------- From 515aecce2eb6c15d6b652dd2a32568c5b304f42c Mon Sep 17 00:00:00 2001 From: DaanVanHauwermeiren Date: Sat, 10 Mar 2018 16:30:57 +0100 Subject: [PATCH 5/7] PEP8: add one more space before 'hippo' --- pandas/core/series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index c3f975e0eafbd..3e5ef9d49aa83 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2778,7 +2778,7 @@ def isin(self, values): -------- >>> s = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama', - ... 'hippo'], name='animal') + ... 'hippo'], name='animal') >>> s.isin(['cow', 'lama']) 0 True 1 True From c17e4235f70fad03273ba63736f499b3dc461ebd Mon Sep 17 00:00:00 2001 From: DaanVanHauwermeiren Date: Sat, 10 Mar 2018 16:41:32 +0100 Subject: [PATCH 6/7] update extended summary --- pandas/core/series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 3e5ef9d49aa83..9c9f7536c9f23 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2748,7 +2748,7 @@ def isin(self, values): Check whether ``values`` are contained in Series. Return a boolean Series showing whether each element in the Series - is exactly contained in the passed sequence of ``values``. + matches an element in the passed sequence of ``values`` exactly. Parameters ---------- From 0cfbefb9d27bf7809e1d79d08731b118174cf7fd Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Sat, 10 Mar 2018 17:24:53 +0100 Subject: [PATCH 7/7] Update series.py --- pandas/core/series.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 9c9f7536c9f23..72f375c155e99 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2745,21 +2745,21 @@ def _take(self, indices, axis=0, convert=True, is_copy=False): def isin(self, values): """ - Check whether ``values`` are contained in Series. + Check whether `values` are contained in Series. Return a boolean Series showing whether each element in the Series - matches an element in the passed sequence of ``values`` exactly. + matches an element in the passed sequence of `values` exactly. Parameters ---------- values : set or list-like The sequence of values to test. Passing in a single string will raise a ``TypeError``. Instead, turn a single string into a - ``list`` of one element. + list of one element. .. versionadded:: 0.18.1 - Support for values as a set. + Support for values as a set. Returns ------- @@ -2768,7 +2768,7 @@ def isin(self, values): Raises ------ TypeError - * If ``values`` is a string + * If `values` is a string See Also --------