Different Values in a Column

Learn how to find the distinct values in a column of a Pandas DataFrame.

Using the unique and nunique functions

The columns in a DataFrame might be categorical or continuous. The categorical columns may have many distinct but finite numbers of values, whereas continuous ones can take infinitely many values. In this sense, the columns can be considered as either discrete or categorical random variables.

Checking the number of distinct values in a categorical column is an essential part of exploratory data analysis. The nunique function returns the number of distinct values in a column and the unique function actually shows the unique values. We can apply them to the product group column in the sales.

Get hands-on with 1200+ tech skills courses.