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
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.