@@ -3112,8 +3112,11 @@ def map(self, mapper, na_action=None):
3112
3112
3113
3113
def isin (self , values , level = None ):
3114
3114
"""
3115
+ Boolean array on existence of index values in `values`.
3116
+
3115
3117
Compute boolean array of whether each index value is found in the
3116
- passed set of values.
3118
+ passed set of values. Length of the returned boolean array matches
3119
+ the length of the index.
3117
3120
3118
3121
Parameters
3119
3122
----------
@@ -3122,23 +3125,67 @@ def isin(self, values, level=None):
3122
3125
3123
3126
.. versionadded:: 0.18.1
3124
3127
3125
- Support for values as a set
3128
+ Support for values as a set.
3126
3129
3127
- level : str or int, optional
3130
+ level : str or int, optional in the case of Index, compulsory on
3131
+ MultiIndex
3128
3132
Name or position of the index level to use (if the index is a
3129
3133
MultiIndex).
3130
3134
3135
+ Returns
3136
+ -------
3137
+ is_contained : ndarray (boolean dtype)
3138
+
3139
+ See also
3140
+ --------
3141
+ DatetimeIndex.isin : an Index of :class:`Datetime` s
3142
+ TimedeltaIndex : an Index of :class:`Timedelta` s
3143
+ PeriodIndex : an Index of :class:`Period` s
3144
+ MultiIndex.isin : Same for `MultiIndex`
3145
+ NumericIndex.isin : Same for `Int64Index`, `UInt64Index`,
3146
+ `Float64Index`
3147
+
3131
3148
Notes
3132
3149
-----
3133
3150
If `level` is specified:
3134
3151
3135
3152
- if it is the name of one *and only one* index level, use that level;
3136
3153
- otherwise it should be a number indicating level position.
3137
3154
3138
- Returns
3139
- -------
3140
- is_contained : ndarray (boolean dtype)
3155
+ Examples
3156
+ --------
3157
+ >>> idx = pd.Index([1,2,3])
3158
+ >>> idx
3159
+ Int64Index([1, 2, 3], dtype='int64')
3160
+
3161
+ Check whether a value is in the Index:
3162
+ >>> idx.isin([1])
3163
+ array([ True, False, False])
3164
+
3165
+ >>> midx = pd.MultiIndex.from_arrays([[1,2,3],
3166
+ ... ['red','blue','green']],
3167
+ ... names=('number', 'color'))
3168
+ >>> midx
3169
+ MultiIndex(levels=[[1, 2, 3], ['blue', 'green', 'red']],\
3170
+ labels=[[0, 1, 2], [2, 0, 1]],\
3171
+ names=['number', 'color'])
3172
+
3173
+ Check whether a string index value is in the 'color' level of the
3174
+ MultiIndex:
3175
+
3176
+ >>> midx.isin(['red'],'color')
3177
+ array([ True, False, False])
3178
+
3179
+ >>> dates = ['3/11/2000', '3/12/2000', '3/13/2000']
3180
+ >>> dti = pd.to_datetime(dates)
3181
+ >>> dti
3182
+ DatetimeIndex(['2000-03-11', '2000-03-12', '2000-03-13'],\
3183
+ dtype='datetime64[ns]', freq=None)
3184
+
3185
+ Check whether a datetime index value is in the DatetimeIndex:
3141
3186
3187
+ >>> dti.isin(['3/11/2000'])
3188
+ array([ True, False, False])
3142
3189
"""
3143
3190
if level is not None :
3144
3191
self ._validate_index_level (level )
0 commit comments