Commit 035053a0 authored by 高雅喆's avatar 高雅喆

update

parent 17a27d53
...@@ -156,14 +156,22 @@ def get_user_tag_score(cl_id, all_word_tags, size=10): ...@@ -156,14 +156,22 @@ def get_user_tag_score(cl_id, all_word_tags, size=10):
user_df_service_sql = "select time,cl_id,score_type,tag_id,tag_referrer,action from user_new_tag_log " \ user_df_service_sql = "select time,cl_id,score_type,tag_id,tag_referrer,action from user_new_tag_log " \
"where cl_id ='{}' and action != 'do_search' ".format(cl_id) "where cl_id ='{}' and action != 'do_search' ".format(cl_id)
cur_jerry_test.execute(user_df_service_sql) cur_jerry_test.execute(user_df_service_sql)
user_log_df = pd.DataFrame(list(cur_jerry_test.fetchall())) data = list(cur_jerry_test.fetchall())
user_log_df.columns = ["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"] if data:
user_log_df = pd.DataFrame(data)
user_log_df.columns = ["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"]
else:
user_log_df = pd.DataFrame(columns=["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"])
# 用户的搜索行为 # 用户的搜索行为
user_df_search_sql = "select time,cl_id,score_type,tag_id,tag_referrer,action from user_new_tag_log " \ user_df_search_sql = "select time,cl_id,score_type,tag_id,tag_referrer,action from user_new_tag_log " \
"where cl_id ='{}' and action = 'do_search'".format(cl_id) "where cl_id ='{}' and action = 'do_search'".format(cl_id)
cur_jerry_test.execute(user_df_search_sql) cur_jerry_test.execute(user_df_search_sql)
user_df_search = pd.DataFrame(list(cur_jerry_test.fetchall())) data_search = list(cur_jerry_test.fetchall())
user_df_search.columns = ["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"] if data_search:
user_df_search = pd.DataFrame(data_search)
user_df_search.columns = ["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"]
else:
user_df_search = pd.DataFrame(columns=["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"])
# 搜索词转成tag # 搜索词转成tag
for index, row in user_df_search.iterrows(): for index, row in user_df_search.iterrows():
......
...@@ -212,7 +212,7 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2 ...@@ -212,7 +212,7 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2
cur_jerry_test.execute(user_df_service_sql) cur_jerry_test.execute(user_df_service_sql)
data = list(cur_jerry_test.fetchall()) data = list(cur_jerry_test.fetchall())
if data: if data:
user_df_service = pd.DataFrame() user_df_service = pd.DataFrame(data)
user_df_service.columns = ["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"] user_df_service.columns = ["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"]
else: else:
user_df_service = pd.DataFrame(columns=["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"]) user_df_service = pd.DataFrame(columns=["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"])
...@@ -222,7 +222,7 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2 ...@@ -222,7 +222,7 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2
cur_jerry_test.execute(user_df_search_sql) cur_jerry_test.execute(user_df_search_sql)
data_search = list(cur_jerry_test.fetchall()) data_search = list(cur_jerry_test.fetchall())
if data_search: if data_search:
user_df_search = pd.DataFrame() user_df_search = pd.DataFrame(data_search)
user_df_search.columns = ["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"] user_df_search.columns = ["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"]
else: else:
user_df_search = pd.DataFrame(columns=["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"]) user_df_search = pd.DataFrame(columns=["time", "cl_id", "score_type", "tag_id", "tag_referrer", "action"])
......
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