Skip to content

How to count unique values in a column dataframe in Python?

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

print (df)
''    1
''      1
''     2
''          3
Name: ID, dtype: int64
See also  Python code snippet - How to preserve white space when joining an array ?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.