w3resource

Pandas DataFrame: mode() function

DataFrame - mode() function

The mode() function is used to get the mode(s) of each element along the selected axis.

The mode of a set of values is the value that appears most often. It can be multiple values.

Syntax:

DataFrame.mode(self, axis=0, numeric_only=False, dropna=True)

Parameters:

Name Description Type/Default Value Required / Optional
axis    

The axis to iterate over while searching for the mode:

  • 0 or ‘index’ : get mode of each column
  • 1 or ‘columns’ : get mode of each row
{0 or ‘index’, 1 or ‘columns’}
Default Value: 0
Required
numeric_only        If True, only apply to numeric columns. bool
Default Value: False
Required
dropna     Don’t consider counts of NaN/NaT. bool
Default Value: True
Required

Returns: DataFrame
The modes of each column or row.

Example:


Download the Pandas DataFrame Notebooks from here.

Previous: DataFrame - min() function
Next: DataFrame - pct_change() function



Follow us on Facebook and Twitter for latest update.