@@ -3396,11 +3396,8 @@ def map(self, mapper, na_action=None):
3396
3396
3397
3397
def isin (self , values , level = None ):
3398
3398
"""
3399
- Return a boolean array where the index values are in `values`.
3400
-
3401
3399
Compute boolean array of whether each index value is found in the
3402
- passed set of values. The length of the returned boolean array matches
3403
- the length of the index.
3400
+ passed set of values.
3404
3401
3405
3402
Parameters
3406
3403
----------
@@ -3409,74 +3406,23 @@ def isin(self, values, level=None):
3409
3406
3410
3407
.. versionadded:: 0.18.1
3411
3408
3412
- Support for values as a set.
3409
+ Support for values as a set
3413
3410
3414
3411
level : str or int, optional
3415
3412
Name or position of the index level to use (if the index is a
3416
- `MultiIndex`).
3417
-
3418
- Returns
3419
- -------
3420
- is_contained : ndarray
3421
- NumPy array of boolean values.
3422
-
3423
- See also
3424
- --------
3425
- Series.isin : Same for Series.
3426
- DataFrame.isin : Same method for DataFrames.
3413
+ MultiIndex).
3427
3414
3428
3415
Notes
3429
3416
-----
3430
- In the case of `MultiIndex` you must either specify `values` as a
3431
- list-like object containing tuples that are the same length as the
3432
- number of levels, or specify `level`. Otherwise it will raise a
3433
- ``ValueError``.
3434
-
3435
3417
If `level` is specified:
3436
3418
3437
3419
- if it is the name of one *and only one* index level, use that level;
3438
3420
- otherwise it should be a number indicating level position.
3439
3421
3440
- Examples
3441
- --------
3442
- >>> idx = pd.Index([1,2,3])
3443
- >>> idx
3444
- Int64Index([1, 2, 3], dtype='int64')
3445
-
3446
- Check whether each index value in a list of values.
3447
- >>> idx.isin([1, 4])
3448
- array([ True, False, False])
3449
-
3450
- >>> midx = pd.MultiIndex.from_arrays([[1,2,3],
3451
- ... ['red', 'blue', 'green']],
3452
- ... names=('number', 'color'))
3453
- >>> midx
3454
- MultiIndex(levels=[[1, 2, 3], ['blue', 'green', 'red']],
3455
- labels=[[0, 1, 2], [2, 0, 1]],
3456
- names=['number', 'color'])
3457
-
3458
- Check whether the strings in the 'color' level of the MultiIndex
3459
- are in a list of colors.
3460
-
3461
- >>> midx.isin(['red', 'orange', 'yellow'], level='color')
3462
- array([ True, False, False])
3463
-
3464
- To check across the levels of a MultiIndex, pass a list of tuples:
3465
-
3466
- >>> midx.isin([(1, 'red'), (3, 'red')])
3467
- array([ True, False, False])
3468
-
3469
- For a DatetimeIndex, string values in `values` are converted to
3470
- Timestamps.
3471
-
3472
- >>> dates = ['2000-03-11', '2000-03-12', '2000-03-13']
3473
- >>> dti = pd.to_datetime(dates)
3474
- >>> dti
3475
- DatetimeIndex(['2000-03-11', '2000-03-12', '2000-03-13'],
3476
- dtype='datetime64[ns]', freq=None)
3422
+ Returns
3423
+ -------
3424
+ is_contained : ndarray (boolean dtype)
3477
3425
3478
- >>> dti.isin(['2000-03-11'])
3479
- array([ True, False, False])
3480
3426
"""
3481
3427
if level is not None :
3482
3428
self ._validate_index_level (level )
0 commit comments