How to count duplicates in Pandas Dataframe? Last Updated : 28 Jul, 2020 Comments Improve Suggest changes Like Article Like Report Let us see how to count duplicates in a Pandas DataFrame. Our task is to count the number of duplicate entries in a single column and multiple columns. Under a single column : We will be using the pivot_table() function to count the duplicates in a single column. The column in which the duplicates are to be found will be passed as the value of the index parameter. The value of aggfunc will be 'size'. python3 # importing the module import pandas as pd # creating the DataFrame df = pd.DataFrame({'Name' : ['Mukul', 'Rohan', 'Mayank', 'Sundar', 'Aakash'], 'Course' : ['BCA', 'BBA', 'BCA', 'MBA', 'BBA'], 'Location' : ['Saharanpur', 'Meerut', 'Agra', 'Saharanpur', 'Meerut']}) # counting the duplicates dups = df.pivot_table(index = ['Course'], aggfunc ='size') # displaying the duplicate Series print(dups) Output : Across multiple columns : We will be using the pivot_table() function to count the duplicates across multiple columns. The columns in which the duplicates are to be found will be passed as the value of the index parameter as a list. The value of aggfunc will be 'size'. python3 # importing the module import pandas as pd # creating the DataFrame df = pd.DataFrame({'Name' : ['Mukul', 'Rohan', 'Mayank', 'Sundar', 'Aakash'], 'Course' : ['BCA', 'BBA', 'BCA', 'MBA', 'BBA'], 'Location' : ['Saharanpur', 'Meerut', 'Agra', 'Saharanpur', 'Meerut']}) # counting the duplicates dups = df.pivot_table(index = ['Course', 'Location'], aggfunc ='size') # displaying the duplicate Series print(dups) Output Comment More infoAdvertise with us Next Article How to count duplicates in Pandas Dataframe? M mukulsomukesh Follow Improve Article Tags : Python Python-pandas Python pandas-dataFrame Practice Tags : python Similar Reads How to Find & Drop duplicate columns in a Pandas DataFrame? Letâs discuss How to Find and drop duplicate columns in a Pandas DataFrame. First, Letâs create a simple Dataframe with column names 'Name', 'Age', 'Domicile', and 'Age'/'Marks'. Find Duplicate Columns from a DataFrameTo find duplicate columns we need to iterate through all columns of a DataFrame a 4 min read Concatenate Pandas DataFrames Without Duplicates Concatenating Pandas DataFrames refers to combining multiple DataFrames into one, either by stacking them vertically (rows) or horizontally (columns). However, when the DataFrames being combined have overlapping rows or columns, duplicates can occur. The core idea is simple: use the pd.concat method 4 min read Delete duplicates in a Pandas Dataframe based on two columns A dataframe is a two-dimensional, size-mutable tabular data structure with labeled axes (rows and columns). It can contain duplicate entries and to delete them there are several ways. The dataframe contains duplicate values in column order_id and customer_id. Below are the methods to remove duplica 2 min read Python | Pandas dataframe.get_dtype_counts() 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 dataframe.get_dtype_counts() function returns the counts of dtypes in the given 2 min read How to Count Distinct Values of a Pandas Dataframe Column? Let's discuss how to count distinct values of a Pandas DataFrame column. Using pandas.unique()You can use pd.unique()to get all unique values in a column. To count them, apply len()to the result. This method is useful when you want distinct values and their count.Pythonimport pandas as pd # Create D 4 min read Like