答案 0 :(得分:1)
使用groupby
并切片前20
In [4]: df
Out[4]:
language page_name requests bytes
0 en a 1 220
1 eu b 1 620
2 eu b 1 620
3 tr c 1 780
4 en d 4 620
5 en e 9 1320
In [5]: df.groupby('language')['requests'].sum()
Out[5]:
language
en 14
eu 2
tr 1
Name: requests, dtype: int64
In [6]: df.groupby('language')['requests'].sum()[:20]
Out[6]:
language
en 14
eu 2
tr 1
Name: requests, dtype: int64