Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Index.contains() function return a boolean indicating whether the provided key is in the index. If the input value is present in the Index then it returns
True else it returns
False indicating that the input value is not present in the Index.
Key : Object
Returns : boolean
Example #1: Use
Index.contains() function to check if the the given date is present in the Index.
Let’s check if ‘2016-02-08’ is present in the Index or not.
As we can see in the output, the function has returned True indicating that the value is present in the Index.
Example #2: Use
Index.contains() function to check if the input month is present in the Index or not.
Let’s check if ‘May’ is present in the Index or not
- Python | pandas.map()
- Python | Pandas dataframe.all()
- Python | Pandas Series.where
- Python | Pandas Series.xs
- Python | Pandas Series.str.contains()
- Python | Pandas TimedeltaIndex.name
- Python | Pandas Series.iat
- Python | Pandas DataFrame.abs()
- Python | Pandas Series.var
- Python | Pandas dataframe.max()
- Python | Pandas Timestamp.dst
- Python | Pandas dataframe.div()
- Python | Pandas Series.lt()
- Python | Pandas Timestamp.tz
- Python | Pandas Series.agg()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.