Commit ffa259c7 authored by 王志伟's avatar 王志伟

数据指标波动假设检验统计

parent 1059174e
...@@ -170,7 +170,7 @@ def get_fivedate(): ...@@ -170,7 +170,7 @@ def get_fivedate():
return someday return someday
five_days=get_fivedate() five_days=get_fivedate()
#获取最近5天的数据 #获取最近5天的数据,此函数只适用于on_click_diary_card表格,具体原因可以查看数据代码
def chi_DATA_recently(x,y,z,q,t1,t2): def chi_DATA_recently(x,y,z,q,t1,t2):
sql_cid = "select AVG({0}+{1}),AVG({2}) from {3} \ sql_cid = "select AVG({0}+{1}),AVG({2}) from {3} \
where stat_date >= '{4}' and stat_date < '{5}' ".format(x,y,z,q,t1,t2) where stat_date >= '{4}' and stat_date < '{5}' ".format(x,y,z,q,t1,t2)
...@@ -180,6 +180,17 @@ def chi_DATA_yesterday(x,y,z,q,t1): ...@@ -180,6 +180,17 @@ def chi_DATA_yesterday(x,y,z,q,t1):
sql_cid = "select {0}+{1},{2} from {3} where stat_date='{4}' ".format(x,y,z,q,t1) sql_cid = "select {0}+{1},{2} from {3} where stat_date='{4}' ".format(x,y,z,q,t1)
CVR_DATA_yesterday = con_sql(sql_cid)[0] CVR_DATA_yesterday = con_sql(sql_cid)[0]
return CVR_DATA_yesterday return CVR_DATA_yesterday
#获取最近5天的数据
def chi_DATA_recently_all(x,y,z,q,t1,t2):
sql_cid = "select AVG({0}),AVG({1}) from {2} \
where stat_date >= '{3}' and stat_date < '{4}' ".format(x,y,z,t1,t2)
CVR_DATA_recently = con_sql(sql_cid)[0]
return CVR_DATA_recently
def chi_DATA_yesterday_all(x,y,z,q,t1):
sql_cid = "select {0},{1} from {2} where stat_date='{3}' ".format(x,y,z,t1)
CVR_DATA_yesterday = con_sql(sql_cid)[0]
return CVR_DATA_yesterday
#整理数据 #整理数据
def data_cal(x,y): def data_cal(x,y):
...@@ -227,8 +238,8 @@ temp1_old=[float(str(Decimal(chi_ctr_precise_old_recently[i]).quantize(Decimal(' ...@@ -227,8 +238,8 @@ temp1_old=[float(str(Decimal(chi_ctr_precise_old_recently[i]).quantize(Decimal('
chi_ctr_precise_old_yesterday=chi_DATA_yesterday("clk_count_oldUser_all_a","clk_count_oldUser_all_b","imp_count_oldUser_all_precise","on_click_diary_card",yesterday) chi_ctr_precise_old_yesterday=chi_DATA_yesterday("clk_count_oldUser_all_a","clk_count_oldUser_all_b","imp_count_oldUser_all_precise","on_click_diary_card",yesterday)
temp2_old=[float(chi_ctr_precise_old_yesterday[i]) for i in range(len(chi_ctr_precise_old_yesterday))] temp2_old=[float(chi_ctr_precise_old_yesterday[i]) for i in range(len(chi_ctr_precise_old_yesterday))]
# print(temp2) # print(temp2)
tst_old=data_cal(temp1_old,temp2_old) ctr_tst_old=data_cal(temp1_old,temp2_old)
chi_cal(tst_old) chi_cal(ctr_tst_old)
#新用户精准点击曝光数据(首页精选日记本列表on_click_diary_card) #新用户精准点击曝光数据(首页精选日记本列表on_click_diary_card)
print("【2】(精准曝光)首页精选日记本列表新用户ctr数据波动假设检验结果:") print("【2】(精准曝光)首页精选日记本列表新用户ctr数据波动假设检验结果:")
...@@ -238,8 +249,51 @@ temp1_new=[float(str(Decimal(chi_ctr_precise_new_recently[i]).quantize(Decimal(' ...@@ -238,8 +249,51 @@ temp1_new=[float(str(Decimal(chi_ctr_precise_new_recently[i]).quantize(Decimal('
chi_ctr_precise_new_yesterday=chi_DATA_yesterday("clk_count_newUser_all_a","clk_count_newUser_all_b","imp_count_newUser_all_precise","on_click_diary_card",yesterday) chi_ctr_precise_new_yesterday=chi_DATA_yesterday("clk_count_newUser_all_a","clk_count_newUser_all_b","imp_count_newUser_all_precise","on_click_diary_card",yesterday)
temp2_new=[float(chi_ctr_precise_new_yesterday[i]) for i in range(len(chi_ctr_precise_new_yesterday))] temp2_new=[float(chi_ctr_precise_new_yesterday[i]) for i in range(len(chi_ctr_precise_new_yesterday))]
# print(temp2) # print(temp2)
tst_new=data_cal(temp1_new,temp2_new) ctr_tst_new=data_cal(temp1_new,temp2_new)
chi_cal(tst_new) chi_cal(ctr_tst_new)
#老用户美购转化数据
print("【3】老用户CVR数据波动假设检验结果:")
chi_cvr_old_recently=chi_DATA_recently_all("diary_meigou_oldUser","diary_clk_oldUser","diary_meigou_crv",five_days,yesterday)
cvr_old=[float(str(Decimal(chi_cvr_old_recently[i]).quantize(Decimal('0.0')))) for i in range(len(chi_cvr_old_recently))]
# print(temp1)
chi_cvr_old_yesterday=chi_DATA_yesterday_all("diary_meigou_oldUser","diary_clk_oldUser","diary_meigou_crv",yesterday)
cvr_old2=[float(chi_cvr_old_yesterday[i]) for i in range(len(chi_cvr_old_yesterday))]
# print(temp2)
cvr_tst_old=data_cal(cvr_old,cvr_old2)
chi_cal(cvr_tst_old)
#老用户美购转化数据
print("【3】新用户CVR数据波动假设检验结果:")
chi_cvr_new_recently=chi_DATA_recently_all("diary_meigou_newUser","diary_clk_newUser","diary_meigou_crv",five_days,yesterday)
cvr_new=[float(str(Decimal(chi_cvr_new_recently[i]).quantize(Decimal('0.0')))) for i in range(len(chi_cvr_new_recently))]
# print(temp1)
chi_cvr_new_yesterday=chi_DATA_yesterday_all("diary_meigou_newUser","diary_clk_newUser","diary_meigou_crv",yesterday)
cvr_new2=[float(chi_cvr_new_yesterday[i]) for i in range(len(chi_cvr_new_yesterday))]
# print(temp2)
cvr_tst_new=data_cal(cvr_new,cvr_new2)
chi_cal(cvr_tst_new)
#老用户美购转化数据
print("【3】老用户CT-CVR数据波动假设检验结果:")
chi_ctcvr_old_recently=chi_DATA_recently_all("diary_meigou_oldUser","diary_exp_oldUser","diary_meigou_crv",five_days,yesterday)
ctcvr_old=[float(str(Decimal(chi_ctcvr_old_recently[i]).quantize(Decimal('0.0')))) for i in range(len(chi_ctcvr_old_recently))]
# print(temp1)
chi_ctcvr_old_yesterday=chi_DATA_yesterday_all("diary_meigou_oldUser","diary_exp_oldUser","diary_meigou_crv",yesterday)
ctcvr_old2=[float(chi_ctcvr_old_yesterday[i]) for i in range(len(chi_ctcvr_old_yesterday))]
# print(temp2)
ctcvr_tst_old=data_cal(ctcvr_old,ctcvr_old2)
chi_cal(ctcvr_tst_old)
#老用户美购转化数据
print("【3】新用户CT-CVR数据波动假设检验结果:")
chi_ctcvr_new_recently=chi_DATA_recently_all("diary_meigou_newUser","diary_exp_newUser","diary_meigou_crv",five_days,yesterday)
ctcvr_new=[float(str(Decimal(chi_ctcvr_new_recently[i]).quantize(Decimal('0.0')))) for i in range(len(chi_ctcvr_new_recently))]
# print(temp1)
chi_ctcvr_new_yesterday=chi_DATA_yesterday_all("diary_meigou_newUser","diary_exp_newUser","diary_meigou_crv",yesterday)
ctcvr_new2=[float(chi_ctcvr_new_yesterday[i]) for i in range(len(chi_ctcvr_new_yesterday))]
# print(temp2)
ctcvr_tst_new=data_cal(ctcvr_new,ctcvr_new2)
chi_cal(ctcvr_tst_new)
# print(chi_ctr_precise_recently) # print(chi_ctr_precise_recently)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment