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

Merge branch 'zhao' into 'master'

用户画像重排增加if判断

See merge request !34
parents 7758bbfd 63edeffc
...@@ -170,33 +170,35 @@ def to_data_base(df): ...@@ -170,33 +170,35 @@ def to_data_base(df):
if __name__ == "__main__": if __name__ == "__main__":
users_list = get_esmm_users()[:2000] users_list = get_esmm_users()
# TODO 删除上面的2000
print("user number") print("user number")
print(len(users_list)) print(len(users_list))
name_tag = get_searchworlds_to_tagid() if len(users_list) > 0:
n = 500 name_tag = get_searchworlds_to_tagid()
split_users_list = [users_list[i:i + n] for i in range(0, len(users_list), n)] n = 500
for child_users_list in split_users_list: split_users_list = [users_list[i:i + n] for i in range(0, len(users_list), n)]
total_samples = list() for child_users_list in split_users_list:
for uid_city in child_users_list: total_samples = list()
tag_list = get_user_profile(uid_city[0]) for uid_city in child_users_list:
queues = get_queues(uid_city[0], uid_city[1]) tag_list = get_user_profile(uid_city[0])
if len(queues) > 0 and len(tag_list) > 0: queues = get_queues(uid_city[0], uid_city[1])
new_native = tag_boost(queues[0], tag_list) if len(queues) > 0 and len(tag_list) > 0:
new_nearby = tag_boost(queues[1], tag_list) new_native = tag_boost(queues[0], tag_list)
new_nearby = tag_boost(queues[1], tag_list)
insert_time = str(datetime.datetime.now().strftime('%Y%m%d%H%M'))
sample = [uid_city[0], uid_city[1], new_native, new_nearby, queues[2], queues[3], insert_time] insert_time = str(datetime.datetime.now().strftime('%Y%m%d%H%M'))
total_samples.append(sample) sample = [uid_city[0], uid_city[1], new_native, new_nearby, queues[2], queues[3], insert_time]
total_samples.append(sample)
if len(total_samples) > 0:
df = pd.DataFrame(total_samples) if len(total_samples) > 0:
df = df.rename(columns={0: "device_id", 1: "city_id",2:"native_queue", df = pd.DataFrame(total_samples)
3:"nearby_queue",4:"nation_queue",5:"megacity_queue",6:"time"}) df = df.rename(columns={0: "device_id", 1: "city_id",2:"native_queue",
3:"nearby_queue",4:"nation_queue",5:"megacity_queue",6:"time"})
to_data_base(df)
to_data_base(df)
else:
print("没有获取到用户")
......
This diff is collapsed.
This diff is collapsed.
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