find number of non unique rows when doing a groupby in pandas code example
Example 1: pandas groupby count unique rows
df = df.groupby(by='domain', as_index=False).agg({'ID': pd.Series.nunique})
print(df)
domain ID
0 fb 1
1 ggl 1
2 twitter 2
3 vk 3
Example 2: dataframe number of unique rows
1
# get the unique values (rows) by retaining last row
2
df.drop_duplicates(keep='last')