w3resource

Pandas DataFrame: nunique() function

DataFrame - nunique() function

The nunique() function is used to count distinct observations over requested axis.

Return Series with number of distinct observations. Can ignore NaN values.

Syntax:

DataFrame.nunique(self, axis=0, dropna=True)

Parameters:

Name Description Type/Default Value Required / Optional
axis The axis to use. 0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise. {0 or ‘index’, 1 or ‘columns’}
Default Value: 0
Required
dropna Don’t include NaN in the counts. bool
Default Value: True
Required

Returns:Series

Example:


Download the Pandas DataFrame Notebooks from here.

Previous: DataFrame - sum() function
Next: DataFrame - add_prefix() function



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/pandas/dataframe/dataframe-nunique.php