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

修改str.cat

parent 6e4b1a7a
...@@ -31,7 +31,7 @@ def get_data(): ...@@ -31,7 +31,7 @@ def get_data():
temp = temp.rename(columns={0: "device_id"}) temp = temp.rename(columns={0: "device_id"})
print("click data ok") print("click data ok")
print(temp.head()) print(temp.head())
df = pd.merge(esmm,temp,on = "device_id") df = pd.merge(esmm,temp,on = "device_id").dropna()
print(df.head()) print(df.head())
...@@ -44,6 +44,7 @@ def get_data(): ...@@ -44,6 +44,7 @@ def get_data():
df["y"] = df["device_id"].str.cat([df["ucity_id"].values.tolist(), df["cid_id"].values.tolist(), df["y"] = df["device_id"].str.cat([df["ucity_id"].values.tolist(), df["cid_id"].values.tolist(),
df["y"].values.tolist(),df["z"].values.tolist()], sep=",") df["y"].values.tolist(),df["z"].values.tolist()], sep=",")
df = df.drop("z", axis=1) df = df.drop("z", axis=1)
print(df.head())
df = df[df["stat_date"] != "2018-11-25"] df = df[df["stat_date"] != "2018-11-25"]
transform(df,"train") transform(df,"train")
df = df[df["stat_date"] == "2018-11-25"] df = df[df["stat_date"] == "2018-11-25"]
...@@ -61,7 +62,7 @@ def transform(df,table): ...@@ -61,7 +62,7 @@ def transform(df,table):
df["ffm"] = df[0].apply(lambda x: x.split(",")[4]) df["ffm"] = df[0].apply(lambda x: x.split(",")[4])
df["seq"] = list(range(df.shape[0])) df["seq"] = list(range(df.shape[0]))
df["seq"] = df["seq"].astype("str") df["seq"] = df["seq"].astype("str")
df["ffm"] = df["seq"].str.cat(df[["y", "ffm"]], sep=",") df["ffm"] = df["seq"].str.cat([df["y"].values.tolist(), df["ffm"].values.tolist()], sep=",")
df["number"] = np.random.randint(1, 2147483647, df.shape[0]) df["number"] = np.random.randint(1, 2147483647, df.shape[0])
df = df.drop(0, axis=1) df = df.drop(0, axis=1)
yconnect = create_engine('mysql+pymysql://root:3SYz54LS9#^9sBvC@10.66.157.22:4000/jerry_test?charset=utf8') yconnect = create_engine('mysql+pymysql://root:3SYz54LS9#^9sBvC@10.66.157.22:4000/jerry_test?charset=utf8')
......
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