Commit e384f10f authored by 张彦钊's avatar 张彦钊

add data

parent de87550c
...@@ -47,8 +47,10 @@ def get_data(): ...@@ -47,8 +47,10 @@ def get_data():
print(df.head()) print(df.head())
print("shape") print("shape")
print(df.shape) print(df.shape)
device_tuple = tuple(df["device_id"].values.tolist()) device_tuple = tuple(set(df["device_id"].values.tolist()))
df = pd.merge(df,get_statistics(device_tuple),on="device_id",how='left').fillna(0) a = device_tuple[0:2]
print(a)
df = pd.merge(df,get_statistics(a),on="device_id",how='left').fillna(0)
print("merge") print("merge")
print(df.head()) print(df.head())
print("shape") print("shape")
...@@ -99,6 +101,7 @@ def get_statistics(device_tuple): ...@@ -99,6 +101,7 @@ def get_statistics(device_tuple):
db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='eagle') db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='eagle')
sql = "select device_id,device_type,channel,total,精选,直播,鼻部,眼部,微整,牙齿,轮廓,美肤抗衰," \ sql = "select device_id,device_type,channel,total,精选,直播,鼻部,眼部,微整,牙齿,轮廓,美肤抗衰," \
"吸脂,脂肪填充,隆胸,私密,毛发管理,公立,韩国 from home_tab_click where device_id in {}".format(device_tuple) "吸脂,脂肪填充,隆胸,私密,毛发管理,公立,韩国 from home_tab_click where device_id in {}".format(device_tuple)
print(sql)
df = con_sql(db, sql) df = con_sql(db, sql)
df = df.rename(columns={0:"device_id",1:"device_type",2:"channel",3:"total"}) df = df.rename(columns={0:"device_id",1:"device_type",2:"channel",3:"total"})
for i in df.columns.difference(["device_id", "device_type","channel","total"]): for i in df.columns.difference(["device_id", "device_type","channel","total"]):
......
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