Commit 9d70d94d authored by 张彦钊's avatar 张彦钊

change transform

parent 5f47c101
...@@ -107,20 +107,14 @@ def transform(df,validate_date): ...@@ -107,20 +107,14 @@ def transform(df,validate_date):
def get_statistics(): def get_statistics():
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,total,精选,直播,鼻部,眼部,微整,牙齿,轮廓,美肤抗衰," \ sql = "select device_id,device_type,total,精选,直播,鼻部,眼部,微整,牙齿,轮廓,美肤抗衰," \
"吸脂,脂肪填充,隆胸,私密,毛发管理,公立,韩国 from home_tab_click limit 200" "吸脂,脂肪填充,隆胸,私密,毛发管理,公立,韩国 from home_tab_click"
df = con_sql(db, sql).drop_duplicates() df = con_sql(db, sql)
df = df.rename(columns={0:"device_id",1:"os",2:"total"}) df = df.rename(columns={0:"device_id",1:"os",2:"total"})
for i in df.columns.difference(["device_id", "os","total"]): for i in df.columns.difference(["device_id", "os","total"]):
df[i] = df[i]/df["total"] df[i] = df[i]/df["total"]
df[i] = df[i].apply(lambda x: format(x,".4f")) df[i] = df[i].apply(lambda x: format(x,".4f"))
df[i] = df[i].astype("float") df[i] = df[i].astype("float")
df = df.drop("total", axis=1) df = df.drop("total", axis=1)
df["y"] = 1
model = multiFFMFormatPandas()
df = model.fit_transform(df, y="y", n=100000, processes=18)
df = pd.DataFrame(df)
print(df.head())
return df return df
...@@ -231,6 +225,6 @@ class multiFFMFormatPandas: ...@@ -231,6 +225,6 @@ class multiFFMFormatPandas:
if __name__ == "__main__": if __name__ == "__main__":
path = "/home/gmuser/ffm/" path = "/home/gmuser/ffm/"
# get_data() get_data()
get_statistics()
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