pandas.Index.contains
-
Index.contains(key)
[source] -
Return a boolean indicating whether the provided key is in the index.
Parameters: -
key : label
-
The key to check if it is present in the index.
Returns: - bool
-
Whether the key search is in the index.
See also
-
Index.isin
- Returns an ndarray of boolean dtype indicating whether the list-like key is in the index.
Examples
>>> idx = pd.Index([1, 2, 3, 4]) >>> idx Int64Index([1, 2, 3, 4], dtype='int64')
>>> idx.contains(2) True >>> idx.contains(6) False
This is equivalent to:
>>> 2 in idx True >>> 6 in idx False
-
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.24.2/reference/api/pandas.Index.contains.html