isin(self, values, level=None) -> 'np.ndarray'
Compute boolean array of whether each index value is found in the passed set of values. The length of the returned boolean array matches the length of the index.
In the case of MultiIndex
you must either specify :None:None:`values`
as a list-like object containing tuples that are the same length as the number of levels, or specify :None:None:`level`
. Otherwise it will raise a ValueError
.
If :None:None:`level`
is specified:
if it is the name of one and only one index level, use that level;
otherwise it should be a number indicating level position.
Sought values.
Name or position of the index level to use (if the index is a MultiIndex
).
NumPy array of boolean values.
Return a boolean array where the index values are in :None:None:`values`
.
DataFrame.isin
Same method for DataFrames.
Series.isin
Same for Series.
>>> idx = pd.Index([1,2,3])
... idx Int64Index([1, 2, 3], dtype='int64')
Check whether each index value in a list of values.
This example is valid syntax, but we were not able to check execution>>> idx.isin([1, 4]) array([ True, False, False])This example is valid syntax, but we were not able to check execution
>>> midx = pd.MultiIndex.from_arrays([[1,2,3],
... ['red', 'blue', 'green']],
... names=('number', 'color'))
... midx MultiIndex([(1, 'red'), (2, 'blue'), (3, 'green')], names=['number', 'color'])
Check whether the strings in the 'color' level of the MultiIndex are in a list of colors.
This example is valid syntax, but we were not able to check execution>>> midx.isin(['red', 'orange', 'yellow'], level='color') array([ True, False, False])
To check across the levels of a MultiIndex, pass a list of tuples:
This example is valid syntax, but we were not able to check execution>>> midx.isin([(1, 'red'), (3, 'red')]) array([ True, False, False])
For a DatetimeIndex, string values in :None:None:`values`
are converted to Timestamps.
>>> dates = ['2000-03-11', '2000-03-12', '2000-03-13']This example is valid syntax, but we were not able to check execution
... dti = pd.to_datetime(dates)
... dti DatetimeIndex(['2000-03-11', '2000-03-12', '2000-03-13'], dtype='datetime64[ns]', freq=None)
>>> dti.isin(['2000-03-11']) array([ True, False, False])See :
The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.indexes.base.Index.__contains__
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them