Python | Pandas Index.contains() Last Updated : 16 Oct, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. Pandas 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. Syntax: Index.contains(key) Parameters : Key : Object Returns : boolean Example #1: Use Index.contains() function to check if the given date is present in the Index. Python3 # importing pandas as pd import pandas as pd # Creating the Index idx = pd.Index(['2015-10-31', '2015-12-02', '2016-01-03', '2016-02-08', '2017-05-05']) # Print the Index idx Output : Let's check if '2016-02-08' is present in the Index or not. Python3 1== # Check if input date in present or not. idx.contains('2016-02-08') Output : 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. Python3 # importing pandas as pd import pandas as pd # Creating the Index idx = pd.Index(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']) # Print the Index idx Output : Let's check if 'May' is present in the Index or not Python3 1== # to check if the input month is # part of the Index or not. idx.contains('May') Output : Comment More infoAdvertise with us Next Article Python | Pandas Index.all() S Shubham__Ranjan Follow Improve Article Tags : Technical Scripter Python Python-pandas Python pandas-indexing Practice Tags : python Similar Reads Python | Pandas Index.hasnans Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object that stores the axis labels for all panda's objects. Pandas Index.hasnans attribute return True if there is any missing value in the given Index object otherwise it returns False indicating there are 2 min read Python | Pandas Index.any() 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. Pandas Index.any() function checks if any of the elements in the index are true or not 2 min read Python | Pandas Index.asof() 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. Pandas Index.asof() function returns return the label from the index, or, if not prese 2 min read Python | Pandas Index.flags Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects. Pandas Index.flags attribute return the status of all the flags for the given Index object. Syntax: Index.flags Parameter : None Returns : status o 2 min read Python | Pandas Index.all() 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. Pandas Index.all() function checks if all the elements in the index are true or not. I 2 min read Python | Pandas Index.equals() 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. Pandas Index.equals() function determine if two Index objects contains the same elemen 2 min read Like