@@ -2814,20 +2814,21 @@ def _take(self, indices, axis=0, convert=True, is_copy=False):
2814
2814
2815
2815
def isin (self , values ):
2816
2816
"""
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.
2820
2821
2821
2822
Parameters
2822
2823
----------
2823
2824
values : set or list-like
2824
2825
The sequence of values to test. Passing in a single string will
2825
2826
raise a ``TypeError``. Instead, turn a single string into a
2826
- `` list`` of one element.
2827
+ list of one element.
2827
2828
2828
2829
.. versionadded:: 0.18.1
2829
2830
2830
- Support for values as a set
2831
+ Support for values as a set.
2831
2832
2832
2833
Returns
2833
2834
-------
@@ -2836,31 +2837,37 @@ def isin(self, values):
2836
2837
Raises
2837
2838
------
2838
2839
TypeError
2839
- * If `` values` ` is a string
2840
+ * If `values` is a string
2840
2841
2841
2842
See Also
2842
2843
--------
2843
- pandas.DataFrame.isin
2844
+ pandas.DataFrame.isin : equivalent method on DataFrame
2844
2845
2845
2846
Examples
2846
2847
--------
2847
2848
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'])
2850
2852
0 True
2851
- 1 False
2853
+ 1 True
2852
2854
2 True
2853
- dtype: bool
2855
+ 3 False
2856
+ 4 True
2857
+ 5 False
2858
+ Name: animal, dtype: bool
2854
2859
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
2856
2861
a list of one element instead:
2857
2862
2858
- >>> s.isin(['a '])
2863
+ >>> s.isin(['lama '])
2859
2864
0 True
2860
2865
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
2864
2871
"""
2865
2872
result = algorithms .isin (com ._values_from_object (self ), values )
2866
2873
return self ._constructor (result , index = self .index ).__finalize__ (self )
0 commit comments