Skip to content

Commit b18d848

Browse files
committed
Updated Index.isin based on reviews; eg. linebreak formatting
1 parent 1e665ab commit b18d848

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

pandas/core/indexes/base.py

+21-17
Original file line numberDiff line numberDiff line change
@@ -3396,10 +3396,10 @@ def map(self, mapper, na_action=None):
33963396

33973397
def isin(self, values, level=None):
33983398
"""
3399-
Boolean array on existence of index values in `values`.
3399+
Return a boolean array where the index values are in `values`.
34003400
34013401
Compute boolean array of whether each index value is found in the
3402-
passed set of values. Length of the returned boolean array matches
3402+
passed set of values. The length of the returned boolean array matches
34033403
the length of the index.
34043404
34053405
Parameters
@@ -3411,26 +3411,25 @@ def isin(self, values, level=None):
34113411
34123412
Support for values as a set.
34133413
3414-
level : str or int, optional in the case of Index, compulsory on
3415-
MultiIndex
3414+
level : str or int, optional
34163415
Name or position of the index level to use (if the index is a
3417-
MultiIndex).
3416+
`MultiIndex`).
34183417
34193418
Returns
34203419
-------
34213420
is_contained : ndarray (boolean dtype)
34223421
34233422
See also
34243423
--------
3425-
DatetimeIndex.isin : an Index of :class:`Datetime` s
3426-
TimedeltaIndex : an Index of :class:`Timedelta` s
3427-
PeriodIndex : an Index of :class:`Period` s
3428-
MultiIndex.isin : Same for `MultiIndex`
3429-
NumericIndex.isin : Same for `Int64Index`, `UInt64Index`,
3430-
`Float64Index`
3424+
Series.isin: same for :class:`~pandas.Series`
34313425
34323426
Notes
34333427
-----
3428+
In the case of `MultiIndex` you must either specify `values` as a
3429+
list-like object containing tuples that are the same length as the
3430+
number of levels, or specify `level`. Otherwise it will raise
3431+
`ValueError`.
3432+
34343433
If `level` is specified:
34353434
34363435
- if it is the name of one *and only one* index level, use that level;
@@ -3450,21 +3449,26 @@ def isin(self, values, level=None):
34503449
... ['red','blue','green']],
34513450
... names=('number', 'color'))
34523451
>>> midx
3453-
MultiIndex(levels=[[1, 2, 3], ['blue', 'green', 'red']],\
3454-
labels=[[0, 1, 2], [2, 0, 1]],\
3455-
names=['number', 'color'])
3452+
MultiIndex(levels=[[1, 2, 3], ['blue', 'green', 'red']],
3453+
labels=[[0, 1, 2], [2, 0, 1]],
3454+
names=['number', 'color'])
34563455
34573456
Check whether a string index value is in the 'color' level of the
34583457
MultiIndex:
34593458
3460-
>>> midx.isin(['red'],'color')
3459+
>>> midx.isin(['red'], level='color')
3460+
array([ True, False, False])
3461+
3462+
Check whether a pair of indexes is in the MultiIndex:
3463+
3464+
>>> midx.isin([(1, 'red'), (3, 'red')])
34613465
array([ True, False, False])
34623466
34633467
>>> dates = ['3/11/2000', '3/12/2000', '3/13/2000']
34643468
>>> dti = pd.to_datetime(dates)
34653469
>>> dti
3466-
DatetimeIndex(['2000-03-11', '2000-03-12', '2000-03-13'],\
3467-
dtype='datetime64[ns]', freq=None)
3470+
DatetimeIndex(['2000-03-11', '2000-03-12', '2000-03-13'],
3471+
dtype='datetime64[ns]', freq=None)
34683472
34693473
Check whether a datetime index value is in the DatetimeIndex:
34703474

0 commit comments

Comments
 (0)