Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: update the Series.isin docstring #20175

Merged
merged 7 commits into from
Mar 10, 2018
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2745,9 +2745,10 @@ 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
is exactly contained in the passed sequence of ``values``.

Parameters
----------
Expand All @@ -2758,7 +2759,7 @@ def isin(self, values):

.. versionadded:: 0.18.1

Support for values as a set
Support for values as a set.

Returns
-------
Expand All @@ -2771,27 +2772,33 @@ def isin(self, values):

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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8: add one more space before 'hippo'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated in 515aecc

>>> 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