Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #groupby #count #unique #rows
ADD COMMENT
Topic
Name
3+5 =