重复记录的平均值



我有下面的输入表

客户价格48300<150800>133200
交易收入
12456 2300 21
12456 5200 29
78901 3000 30 90000
676512 5200 24 124800
676512 7400 18

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

最新更新