""" @author: luojunhui """ import json import pandas as pd with open("AccountInfo.json", encoding="utf-8") as f: account_base_info = json.loads(f.read()) new_d = {} for key in account_base_info: value = account_base_info[key] name = value['accountName'] position = value['position'] read_avg = value['readAvg'] new_key = "{}_{}".format(name, position) new_d[new_key] = read_avg df = pd.read_excel("非实验数据.xlsx") L = [] a = 0 b = 0 for line in df.values.tolist(): dt = line[0] account_name = line[1] title = line[2] link = line[3] pos = line[4] read = line[5] avg_read = new_d.get("{}_{}".format(account_name, pos), 0) if avg_read: avg_times = read / avg_read if avg_times > 1.3: is_up = 1 a += 1 else: is_up = 0 b += 1 strategy = line[-7] # if "军事" in strategy or "历史" in strategy: # ac_t = "实验" # else: ac_t = "对照" L.append([dt, account_name, title, link, pos, read, avg_read, avg_times, is_up, ac_t, strategy]) print([dt, account_name, title, link, pos, read, avg_read, avg_times, is_up, ac_t, strategy]) print(b) print(a) print(a + b) print(a / (a + b)) # out_df = pd.DataFrame( # L, # columns=['日期', '账号名称', '标题', '链接', '文章位置', '阅读量', '阅读均值', '阅读均值倍数', '是否晋升', '实验/对照', '冷启品类'] # ) # # out_df.to_excel("result.xlsx", index=False)