Python | Pandas dataframe.mode() Last Updated : 24 Nov, 2018 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 dataframe.mode() function gets the mode(s) of each element along the axis selected. Adds a row for each mode per label, fills in gaps with nan. Note that there could be multiple values returned for the selected axis (when more than one item share the maximum frequency), which is the reason why a dataframe is returned. Syntax: DataFrame.mode(axis=0, numeric_only=False) Parameters : axis : get mode of each column1, get mode of each row numeric_only : if True, only apply to numeric columns Returns : modes : DataFrame (sorted) Example #1: Use mode() function to find the mode over the index axis. Python3 1== # importing pandas as pd import pandas as pd # Creating the dataframe df=pd.DataFrame({"A":[14,4,5,4,1], "B":[5,2,54,3,2], "C":[20,20,7,3,8], "D":[14,3,6,2,6]}) # Print the dataframe df Lets use the dataframe.mode() function to find the mode of dataframe Python3 1== # find mode of dataframe df.mode() Output : Example #2: Use mode() function to find the mode over the column axis Python3 1== # importing pandas as pd import pandas as pd # Creating the dataframe df=pd.DataFrame({"A":[14,4,5,4,1], "B":[5,2,54,3,2], "C":[20,20,7,3,8], "D":[14,3,6,2,6]}) # Print the dataframe df Lets use the dataframe.mode() function to find the mode Python3 1== # axis = 1 indicates over the column axis df.mode(axis = 1) Output : In the 0th and 3rd row, 14 and 3 is the mode, as they have the maximum occurrence (i.e. 2). In rest of the column all element are mode because they have the same frequency of occurrence. Comment More infoAdvertise with us Next Article Python | Pandas DataFrame.empty S Shubham__Ranjan Follow Improve Article Tags : Technical Scripter Python Python-pandas Python pandas-dataFrame Pandas-DataFrame-Methods +1 More Practice Tags : python Similar Reads Python | Pandas dataframe.eq() 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.eq() is a wrapper used for the flexible comparison. It provides a con 3 min read Python | Pandas DataFrame.empty Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. It can be thought of as a dict-like container for Series objects. This is the primary data structure o 2 min read Python | Pandas DataFrame.empty Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. It can be thought of as a dict-like container for Series objects. This is the primary data structure o 2 min read Python | Pandas DataFrame.ftypes Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. It can be thought of as a dict-like container for Series objects. This is the primary data structure o 2 min read Pandas DataFrame.where()-Python DataFrame.where() function replace values in a DataFrame based on a condition. It allows you to keep the original value where a condition is True and replace it with something else e.g., NaN or a custom value where the condition is False. For Example:Pythonimport pandas as pd import numpy as np df = 2 min read Pandas DataFrame.where()-Python DataFrame.where() function replace values in a DataFrame based on a condition. It allows you to keep the original value where a condition is True and replace it with something else e.g., NaN or a custom value where the condition is False. For Example:Pythonimport pandas as pd import numpy as np df = 2 min read Like