Skip to content

Commit e8d1352

Browse files
DaanVanHauwermeirenmyles
authored andcommitted
DOC: update the Series.isin docstring (pandas-dev#20175)
1 parent 128681e commit e8d1352

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

pandas/core/series.py

+23-16
Original file line numberDiff line numberDiff line change
@@ -2814,20 +2814,21 @@ def _take(self, indices, axis=0, convert=True, is_copy=False):
28142814

28152815
def isin(self, values):
28162816
"""
2817-
Return a boolean :class:`~pandas.Series` showing whether each element
2818-
in the :class:`~pandas.Series` is exactly contained in the passed
2819-
sequence of ``values``.
2817+
Check whether `values` are contained in Series.
2818+
2819+
Return a boolean Series showing whether each element in the Series
2820+
matches an element in the passed sequence of `values` exactly.
28202821
28212822
Parameters
28222823
----------
28232824
values : set or list-like
28242825
The sequence of values to test. Passing in a single string will
28252826
raise a ``TypeError``. Instead, turn a single string into a
2826-
``list`` of one element.
2827+
list of one element.
28272828
28282829
.. versionadded:: 0.18.1
28292830
2830-
Support for values as a set
2831+
Support for values as a set.
28312832
28322833
Returns
28332834
-------
@@ -2836,31 +2837,37 @@ def isin(self, values):
28362837
Raises
28372838
------
28382839
TypeError
2839-
* If ``values`` is a string
2840+
* If `values` is a string
28402841
28412842
See Also
28422843
--------
2843-
pandas.DataFrame.isin
2844+
pandas.DataFrame.isin : equivalent method on DataFrame
28442845
28452846
Examples
28462847
--------
28472848
2848-
>>> s = pd.Series(list('abc'))
2849-
>>> s.isin(['a', 'c', 'e'])
2849+
>>> s = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama',
2850+
... 'hippo'], name='animal')
2851+
>>> s.isin(['cow', 'lama'])
28502852
0 True
2851-
1 False
2853+
1 True
28522854
2 True
2853-
dtype: bool
2855+
3 False
2856+
4 True
2857+
5 False
2858+
Name: animal, dtype: bool
28542859
2855-
Passing a single string as ``s.isin('a')`` will raise an error. Use
2860+
Passing a single string as ``s.isin('lama')`` will raise an error. Use
28562861
a list of one element instead:
28572862
2858-
>>> s.isin(['a'])
2863+
>>> s.isin(['lama'])
28592864
0 True
28602865
1 False
2861-
2 False
2862-
dtype: bool
2863-
2866+
2 True
2867+
3 False
2868+
4 True
2869+
5 False
2870+
Name: animal, dtype: bool
28642871
"""
28652872
result = algorithms.isin(com._values_from_object(self), values)
28662873
return self._constructor(result, index=self.index).__finalize__(self)

0 commit comments

Comments
 (0)