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 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 TimedeltaIndex.name
- Python | Pandas Series.xs
- Python | Pandas dataframe.eq()
- Python | Pandas Series.where
- Python | Pandas Series.sum()
- Python | Pandas Index.where
- Python | Pandas Series.ix
- Python | Pandas Series.loc
- Python | Pandas TimedeltaIndex.take()
- Python | Pandas Series.str.contains()
- Python | Pandas dataframe.get()
- Python | Pandas PeriodIndex.second
- Python | Pandas Series.at
- Python | Pandas Series.sem()
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.
Improved By : Akanksha_Rai