自定义函数
#通过自定义函数,实现指标逻辑
#主要指标
def zhibiao_js(x):
name={"cnt":format(x['cnt'].sum(),".0f")
,"yzl":format(x['yz_cnt'].sum()/x['cnt'].sum(),'0.2%')
,"pbq":x['pbq_cnt'].sum()/x['cnt'].sum()}
return pd.Series(name)
#yzp
def y_e(x):
name={'yel':format(x['f_s_same'].sum()/x['cnt'].sum(),"0.1%")}
return pd.Series(name)
#结果组合
pd.merge(
gd_data[gd_data['pz_type']==' yz'].groupby(by='cdate').apply(y_e),
gd_data.groupby(by='cdate').apply(zhibiao_js),on='cdate')
网友评论