how to get number of unique values in pandas code example

Example 1: count unique pandas

df['column'].nunique()

Example 2: how to count number of unique values in a column python

pd.value_counts(df.Account_Type)

Gold        3
Platinum    1
Name: Account_Type, dtype: int64

Example 3: how to count unique values in a column dataframe in python

dataframe.column.nunique()

Example 4: Count unique values Pandas

df = df.groupby('domain')['ID'].nunique()

Example 5: count unique values in python

words = ['a', 'b', 'c', 'a']
unique_words = set(words)             # == set(['a', 'b', 'c'])
unique_word_count = len(unique_words) # == 3