python aggregate count and sum

Solutions on MaxInterview for python aggregate count and sum by the best coders in the world

showing results for - "python aggregate count and sum"
Alycia
08 Mar 2018
1In [110]: (df.groupby('Company Name')
2   .....:    .agg({'Organisation Name':'count', 'Amount': 'sum'})
3   .....:    .reset_index()
4   .....:    .rename(columns={'Organisation Name':'Organisation Count'})
5   .....: )
6Out[110]:
7          Company Name   Amount  Organisation Count
80  Vifor Pharma UK Ltd  4207.93                   5
Sandy
31 Nov 2019
1df.groupby('Company Name').agg(MySum=('Amount', 'sum'), MyCount=('Amount', 'count'))