Skip to content

Commit

Permalink
DOC: update the Series.isin docstring (#20175)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanVanHauwermeiren authored and jorisvandenbossche committed Mar 10, 2018
1 parent ec631ce commit d8181a5
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2814,20 +2814,21 @@ 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``.
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.
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
-------
Expand All @@ -2836,31 +2837,37 @@ def isin(self, values):
Raises
------
TypeError
* If ``values`` is a string
* If `values` is a string
See Also
--------
pandas.DataFrame.isin
pandas.DataFrame.isin : equivalent method on DataFrame
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)
Expand Down

0 comments on commit d8181a5

Please sign in to comment.