Commit 59b6d428 authored by 张彦钊's avatar 张彦钊

add app list

parent 28d237fa
......@@ -29,7 +29,7 @@ def json_format(x):
def sort_app():
db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_prod')
sql = "select device_id,app_list from device_id_applist limit 60"
sql = "select device_id,app_list from device_id_applist"
df = con_sql(db, sql).dropna()
df = df.rename(columns={0: "device_id", 1: "app_list"})
df = df.loc[df["app_list"].apply(is_json)]
......@@ -71,6 +71,8 @@ def sort_app():
df["app_list"] = df["app_list"].apply(json_format)
for i in category.keys():
df[i] = df["app_list"].apply(lambda x: 1 if len(x & category[i]) > 0 else 0)
print(i)
print(df[i].unique())
df = df.drop("app_list",axis=1)
yconnect = create_engine('mysql+pymysql://root:3SYz54LS9#^9sBvC@10.66.157.22:4000/jerry_test?charset=utf8')
pd.io.sql.to_sql(df, "app_list_sort", yconnect, schema='jerry_test', if_exists='replace', index=False)
......
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