Python | Pandas Index.get_duplicates()
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.get_duplicates() function extract duplicated index elements. This function returns a sorted list of index elements which appear more than once in the Index.
Returns : List of duplicated indexes.
Example #1: Use
Index.get_duplicates() function to find all the duplicate values in the Index.
let’s find out all the duplicate values in the Index.
As we can see in the output, the
Index.get_duplicates() function has returned all the values which are having more than one occurrence in the Index.
Example #2: Use
Index.get_duplicates() function to find all the duplicate in the Index. The Index also contains
As we can see in the output we are having some missing values. Lets see how the
Index.get_duplicates() function treats them.
The occurrence of missing values more than once has been treated as duplicates.
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. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course