Commit 48cdc7e5 authored by 赵威's avatar 赵威

add merge value

parent aff23a4b
import functools
import operator
from collections import Counter
from tool import get_tag3_user_log
def merge_values(d1, d2):
ini_dict = [d1, d2]
return dict(functools.reduce(operator.add, map(Counter, ini_dict)))
def update_tag3_user_portrait(cl_id):
user_df = get_tag3_user_log(cl_id)
if not user_df.empty:
user_df["first_solutions"] = list(zip(user_df["first_solutions"].apply(lambda x: x.split(",")), user_df["tag_score"]))
user_df["second_solutions"] = list(zip(user_df["second_solutions"].apply(lambda x: x.split(",")), user_df["tag_score"]))
user_df["first_demands"] = list(zip(user_df["first_demands"].apply(lambda x: x.split(",")), user_df["tag_score"]))
user_df["second_demands"] = list(zip(user_df["second_demands"].apply(lambda x: x.split(",")), user_df["tag_score"]))
user_df["first_positions"] = list(zip(user_df["first_positions"].apply(lambda x: x.split(",")), user_df["tag_score"]))
user_df["second_positions"] = list(zip(user_df["second_positions"].apply(lambda x: x.split(",")), user_df["tag_score"]))
user_df["first_solutions"] = list(
zip(user_df["first_solutions"].apply(lambda x: x.split(",")), user_df["tag_score"]))
user_df["second_solutions"] = list(
zip(user_df["second_solutions"].apply(lambda x: x.split(",")), user_df["tag_score"]))
user_df["first_demands"] = list(
zip(user_df["first_demands"].apply(lambda x: x.split(",")), user_df["tag_score"]))
user_df["second_demands"] = list(
zip(user_df["second_demands"].apply(lambda x: x.split(",")), user_df["tag_score"]))
user_df["first_positions"] = list(
zip(user_df["first_positions"].apply(lambda x: x.split(",")), user_df["tag_score"]))
user_df["second_positions"] = list(
zip(user_df["second_positions"].apply(lambda x: x.split(",")), user_df["tag_score"]))
user_df["projects"] = list(zip(user_df["projects"].apply(lambda x: x.split(",")), user_df["tag_score"]))
user_df["first_solutions_dict"] = user_df["first_solutions"].apply(lambda x: dict(zip(x[0], [x[1]] * len(x[0]))))
user_df["second_solutions_dict"] = user_df["second_solutions"].apply(lambda x: dict(zip(x[0], [x[1]] * len(x[0]))))
user_df["first_demands_dict"] = user_df["first_demands"].apply(lambda x: dict(zip(x[0], [x[1]] * len(x[0]))))
user_df["second_demands_dict"] = user_df["second_demands"].apply(lambda x: dict(zip(x[0], [x[1]] * len(x[0]))))
user_df["first_positions_dict"] = user_df["first_positions"].apply(lambda x: dict(zip(x[0], [x[1]] * len(x[0]))))
user_df["second_positions_dict"] = user_df["second_positions"].apply(lambda x: dict(zip(x[0], [x[1]] * len(x[0]))))
user_df["first_solutions_dict"] = user_df["first_solutions"].apply(
lambda x: dict(zip(x[0], [x[1]] * len(x[0]))))
user_df["second_solutions_dict"] = user_df["second_solutions"].apply(
lambda x: dict(zip(x[0], [x[1]] * len(x[0]))))
user_df["first_demands_dict"] = user_df["first_demands"].apply(
lambda x: dict(zip(x[0], [x[1]] * len(x[0]))))
user_df["second_demands_dict"] = user_df["second_demands"].apply(
lambda x: dict(zip(x[0], [x[1]] * len(x[0]))))
user_df["first_positions_dict"] = user_df["first_positions"].apply(
lambda x: dict(zip(x[0], [x[1]] * len(x[0]))))
user_df["second_positions_dict"] = user_df["second_positions"].apply(
lambda x: dict(zip(x[0], [x[1]] * len(x[0]))))
user_df["projects_dict"] = user_df["projects"].apply(lambda x: dict(zip(x[0], [x[1]] * len(x[0]))))
first_solutions_list = user_df["first_solutions_dict"].tolist()
second_solutions_list = user_df["second_solutions_dict"].tolist()
first_demands_list = user_df["first_demands_list"].tolist()
first_demands_list = user_df["first_demands_dict"].tolist()
second_demands_list = user_df["second_demands_dict"].tolist()
first_positions_list = user_df["first_positions_dict"].tolist()
second_positions_list = user_df["second_positions_dict"].tolist()
projects_list = user_df["projects_dict"].tolist()
print(first_solutions_list)
print(second_solutions_list)
print(first_demands_list)
print(second_demands_list)
print(first_positions_list)
print(second_positions_list)
print(projects_list)
print(merge_values(first_solutions_list), "\n")
print(second_solutions_list, "\n")
print(merge_values(second_solutions_list))
print(first_demands_list, "\n")
print(merge_values(first_demands_list))
if __name__ == "__main__":
......
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