可用率map处理
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
total_data =[ {'event_current_dealer': '陈铁', 'id__count': 66}, {'event_current_dealer': '丁凯', 'id__count': 70}, {'event_current_dealer': '丁志杰', 'id__count': 76}, #相当于item {'event_current_dealer': '郭雁平', 'id__count': 58}, {'event_current_dealer': '王宇', 'id__count': 1}, {'event_current_dealer': '周敬尧', 'id__count': 8}, {'event_current_dealer': '刘晓明', 'id__count': 80}, {'event_current_dealer': '孙奥开', 'id__count': 47}, {'event_current_dealer': '李大鹏', 'id__count': 3}, {'event_current_dealer': '戚文龙', 'id__count': 42}, {'event_current_dealer': 'nan', 'id__count': 4}, {'event_current_dealer': '陈思文', 'id__count': 86}, {'event_current_dealer': '王聪渊', 'id__count': 15}, {'event_current_dealer': '屈蕾', 'id__count': 1} ] hang_data =[ {'event_hang_person': '陈铁', 'id__count': 2}, {'event_hang_person': '丁凯', 'id__count': 1}, {'event_hang_person': '丁志杰', 'id__count': 3}, {'event_hang_person': '郭雁平', 'id__count': 3}, {'event_hang_person': '王宇', 'id__count': 1}, {'event_hang_person': '周敬尧', 'id__count': 2}, {'event_hang_person': '刘晓明', 'id__count': 2}, {'event_hang_person': '王珠珠', 'id__count': 1}, {'event_hang_person': '李大鹏', 'id__count': 2} ] t =[] t_v =[] for item in total_data: t.append(item['event_current_dealer']) t_v.append(item['id__count']) if "nan" in t: t.remove("nan") h = [] h_v = [] for item in hang_data: h.append(item['event_hang_person']) h_v.append(item['id__count']) if "nan" in h: h.remove("nan") # 挂起人是自己的 h_p = set(t).intersection(set(h)) """ {'李大鹏', '陈铁', '郭雁平', '丁凯', '王宇', '丁志杰', '刘晓明', '周敬尧'} """ """ 有挂起率的人员 将数据封装成以下样式: {"李大鹏":10,} """ # print(h_p) t_dict = dict(zip(t,t_v)) h_dict = dict(zip(h,h_v)) t_new_dict = dict() for item in h_p: for k,v in t_dict.items(): if item == k: t_new_dict[item]=v h_new_dict =dict() for item in h_p: for k,v in h_dict.items(): if item == k: h_new_dict[item]=v # print(t_new_dict) # print(h_new_dict) # 按名字排序 t_names =[] for item in t_new_dict: t_names.append(item) t_names.sort(reverse=True) t_last = dict() for item in t_names: for k,v in t_new_dict.items(): if item == k : t_last[item] =v h_last = dict() for item in t_names: for k,v in h_new_dict.items(): if item == k : h_last[item] =v print(t_last) print(h_last) t_last_v =[] for k,v in t_last.items(): t_last_v.append(v) h_last_v =[] for k,v in h_last.items(): h_last_v.append(v) print(t_last_v) print(h_last_v) findal_result = map(lambda x,y:str(round(x/y,2)*100)+"%",h_last_v,t_last_v) print(list(findal_result)) "conet".strip()
技术改变一切