x=[{"id": "z", 'name':"q"},{"id": "v", 'name':"q"},{"id": "a", 'name':"q"},{"id": "z", 'name':"o"}]
p =pd.DataFrame(x)
In [46]: p
Out[46]:
id name
0 z q
1 v q
2 a q
3 z o
In [47]: p.groupby(['id']).size()['z']
Out[47]: 2
In [48]: p.groupby(['name']).size()['q']
Out[48]: 3
网友评论