我有下面的输入表
交易 | 价格收入 | ||
---|---|---|---|
12456 | 2300 | 21 | 48300|
12456 | 5200 | 29 | <150800>|
78901 | 3000 | 30 | 90000 |
676512 | 5200 | 24 | 124800 |
676512 | 7400 | 18 | 133200
groupby在custid上,并表示交易和价格然后计算收入
df2=df.groupby('Custid').mean().astype(int).reset_index()
df2['revenue'] = df2['transactions'] * df2['price']
df2
Custid transactions price revenue
0 12456 3750 25 93750
1 78901 3000 30 90000
2 676512 6300 21 132300