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

Here is what the above code is Doing:
1. Grouping by domain
2. Aggregating the ID column by counting the number of unique values
3. Resetting the index