【发布时间】:2021-08-01 07:10:05
【问题描述】:
我在 AID 级别有以下数据框,我想 Group By 在 CID 上使用 min 优先级,max Ind 值,并计算金额字段的 sum
数据框
AID CID priority amount Ind
100 C100 1 50 1
200 C100 2 100 0
300 C300 5 300 0
400 C300 3 200 0
500 C300 4 150 0
所需的数据帧
CID Priority amount Ind
C100 1 150 1
C300 3 650 0
我试过了
df2=df.groupby(['CID']).min('Priority')
Error: method object is not subscriptable
【问题讨论】: