new_series = df.groupby(by=['a'])['b'].sum() # 意思是对字段a进行分组然后通过字段B进行求和汇总 # 返回Series类型对象。 a会变成index b则成为值