Get Number of Unique Values in a Pandas DataFrame Column

Python

Returns the number of unique values that are present in a Pandas dataframe column.

 1|  unique_values = df['column_name'].nunique()
 2|  print('Number of Unique Values:', unique_values)
Did you find this snippet useful?

Sign up for free to to add this to your code library