Commit 76fd0eb8 authored by 张彦钊's avatar 张彦钊

修改点击率计算

parent 2854543d
......@@ -13,12 +13,11 @@ def get_yesterday_date():
today = datetime.date.today()
yesterday = today - datetime.timedelta(days=1)
yesterday = yesterday.strftime("%Y-%m-%d")
print(yesterday)
return yesterday
#today = datetime.date.today().strftime("%Y%m%d")
#return today
date = get_yesterday_date()
def get_data():
conn2db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='eagle')
cursor = conn2db.cursor()
......@@ -26,7 +25,7 @@ def get_data():
cursor.execute(sql)
result = cursor.fetchall()
df = pd.DataFrame(list(result))
df.to_csv("/data2/ffm/10.3-10.9device_id.csv")
df.to_csv("/data2/ffm/10.3-10.9device_id.csv",index=None)
device_id = tuple(df[0].values.tolist())
cursor.close()
return device_id
......@@ -38,7 +37,7 @@ def ctr():
cursor = db.cursor()
print("点击数:"+str(len(device_id)))
sql_exp = "select count(cid) from data_feed_exposure " \
"where cid_type = 'diary' and stat_date <= '2018-10-09' and stat_date >= '2018-10-07' and " \
"where cid_type = 'diary' and stat_date <= '2018-10-09' and stat_date >= '2018-10-03' and " \
"device_id in {}".format(device_id)
cursor.execute(sql_exp)
exp = cursor.fetchone()[0]
......@@ -48,6 +47,5 @@ def ctr():
if __name__ == "__main__":
ctr()
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