最佳答案
我有一个数据框架,看起来像这样:
Company Name Organisation Name Amount
10118 Vifor Pharma UK Ltd Welsh Assoc for Gastro & Endo 2700.00
10119 Vifor Pharma UK Ltd Welsh IBD Specialist Group, 169.00
10120 Vifor Pharma UK Ltd West Midlands AHSN 1200.00
10121 Vifor Pharma UK Ltd Whittington Hospital 63.00
10122 Vifor Pharma UK Ltd Ysbyty Gwynedd 75.93
How do I sum the Amount
and count the Organisation Name
, to get a new dataframe that looks like this?
Company Name Organisation Count Amount
10118 Vifor Pharma UK Ltd 5 11000.00
我知道如何计算 或者计数:
df.groupby('Company Name').sum()
df.groupby('Company Name').count()
但不知道如何两者兼顾!