Commit 301fbcd0 authored by 张彦钊's avatar 张彦钊

change

parent 1b5adb17
......@@ -11,20 +11,6 @@ def get_yesterday_date():
print(yesterday)
return yesterday
def get_data():
conn2db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='eagle')
cursor = conn2db.cursor()
sql = "select distinct device_id from ffm_diary_queue_temp where device_id regexp '[5|6]$'"
cursor.execute(sql)
result = cursor.fetchall()
device = tuple(pd.DataFrame(list(result))[0].values.tolist())
cursor.close()
print(device[0:2])
return device
def ctr_all():
db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_prod')
cursor = db.cursor()
......@@ -52,9 +38,24 @@ def ctr_all():
df.to_csv(DIRECTORY_PATH+"exp.csv",index=None)
def get_data():
conn2db = pymysql.connect(host='172.16.40.158', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test')
cursor = conn2db.cursor()
sql = "select cid,exp,click from diary_ctr"
cursor.execute(sql)
result = cursor.fetchall()
cursor.close()
return result
if __name__ == "__main__":
DIRECTORY_PATH = "/data2/ffm/"
date = get_yesterday_date()
device_id = get_data()
ctr_all()
DIRECTORY_PATH = "/home/gmuser/"
df = pd.DataFrame(list(get_data()))
print(df.head())
df = df.rename(columns={0:"cid",1:"exp",2:"click"})
df["click"] = df["click"].fillna(0)
df["ctr"] = df["click"]/df["exp"]
print(df.head(6))
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