2列的乘积,进行分组求sum
#2列的乘积,进行分组求sum
(
kc
.astype({'ym_yxq':'datetime64[ns]'})
.query("ym_yxq>'2023-04-18'")
.groupby(['ym_mc','sccj_mc'])
.agg(kc=('kcsl',np.sum),kc2=('kcsl',lambda x:np.sum(x*kc.ymgg_bm)))
.to_excel('/mnt/c/users/xuefeng/downloads/jieguo2.xlsx')
)
评论
发表评论