xxxxxxxxxx
#TO count repetition of each unique values(to find How many times the same-
# unique value is appearing in the data)
item_counts = df["Your_Column"].value_counts()
#Returns Dictionary => {"Value_name" : number_of_appearences}
xxxxxxxxxx
df = df.groupby('domain')['ID'].nunique()
print (df)
domain
'facebook.com' 1
'google.com' 1
'twitter.com' 2
'vk.com' 3
Name: ID, dtype: int64
xxxxxxxxxx
#count unique values in each column
df.nunique()
#count unique values in each row
df.nunique(axis=1)
xxxxxxxxxx
pd.value_counts(df.Account_Type)
Gold 3
Platinum 1
Name: Account_Type, dtype: int64
xxxxxxxxxx
import pandas as pd
# Assuming the DataFrame is already defined and contains the desired column
df = pd.DataFrame({'column_name': ['value1', 'value2', 'value1', 'value3', 'value2']})
# Count the number of unique values in the 'column_name' column
unique_count = df['column_name'].nunique()
# Print the result
print("Number of unique values:", unique_count)