Python | Pandas Index.drop_duplicates() Last Updated : 16 Sep, 2022 Comments Improve Suggest changes Like Article Like Report Pandas Index.drop_duplicates() function return Index with duplicate values removed in Python. Syntax of Pandas Index.drop_duplicates() Syntax: Index.drop_duplicates(labels, errors='raise') Parameters : keep : {‘first’, ‘last’, False} ‘first’ : Drop duplicates except for the first occurrence.(default)‘last’ : Drop duplicates except for the last occurrence. False : Drop all duplicates. Returns : deduplicated: Index Examples of Index.drop_duplicates() The function provides the flexibility to choose which duplicate value to be retained. We can drop all duplicate values from the list or leave the first/last occurrence of the duplicated values. Example 1: Use Index.drop_duplicates() function to drop all the occurrences of the duplicate value. Let's drop all occurrences of duplicate values in the Index except the first occurrence. Python3 # importing pandas as pd import pandas as pd # Creating the Index idx = pd.Index([10, 11, 5, 5, 22, 5, 3, 11]) # drop all duplicate occurrences of the # labels and keep the first occurrence idx.drop_duplicates(keep ='first') print(idx) Output: Example 2: Use Index.drop_duplicate() function to drop all duplicate occurrences of the label. Do not keep any duplicated values in the Index. Python3 # importing pandas as pd import pandas as pd # Creating the Index idx = pd.Index([10, 11, 5, 5, 22, 5, 3, 11]) # drop all duplicate occurrences of the labels idx.drop_duplicates(keep=False) # Print the Index idx Output: Comment More infoAdvertise with us Next Article Python | Pandas Index.drop_duplicates() S Shubham__Ranjan Follow Improve Article Tags : Technical Scripter Python Python-pandas Python pandas-indexing Practice Tags : python Similar Reads Python | Pandas Index.duplicated() The Index.duplicated() method in Pandas is a powerful tool for identifying duplicate values within an index. It returns a boolean array where duplicates are marked as True based on the specified criteria and False denotes unique values or the first occurrence of duplicates. This method is especially 5 min read 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. Pandas Index.get_duplicates() function extract duplicated index elements. This functio 2 min read Python | Pandas Series.drop_duplicates() Pandas Series.drop_duplicates() function returns a series object with duplicate values removed from the given series object. Syntax: Series.drop_duplicates(keep='first', inplace=False) Parameter : keep : {âfirstâ, âlastâ, False}, default âfirstâ inplace : If True, performs operation inplace and retu 2 min read Python | Pandas Index.dropna() 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.dropna() function return Index without NA/NaN values. All the missing val 2 min read Python | Pandas Index.drop() 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.drop() function make new Index with passed list of labels deleted. The fu 2 min read Like