我正在研究函数。我有一个total_列表,我需要从中提取唯一的记录作为Department JobRole的元组列表。我是作为字典列表来做的,但我不能作为元组列表来做
total_list = sorted(list(zip(lista_Monthlyincome, lista_EducationField, lista_Education, lista_Department, lista_TotalWorkingYears, lista_JobRole)))
# [(1009, 'Medical', 1, 'Research & Development', 1, 'Research Scientist'), (1051, 'Life Sciences', 2, 'Research & Development', 0, 'Research Scientist')
def edufield_Dep_JR_dic(lista, educationfield):
all_found = []
for element in total_list:
if element[1] == str(educationfield):
add_to_all_found = True
for element2 in all_found:
for key, value in element2.items():
klucz = key
wartosc = value
if klucz == element[3] and wartosc == element[5]:
add_to_all_found = False
break
if add_to_all_found:
all_found.append({element[3]: element[5]})
return all_found
print(edufield_Dep_JR_dic(total_list, 'Medical'))
在下一步中,我需要添加更多对象来创建部门JobRole Education TotalWorkingYears MonthlyIncome的唯一元组列表。可能(我很抱歉)我无法使用dictionary,因为dictionary有2个对象key:value,所以我只能使用2个对象
目前没有回答
相关问题 更多 >
编程相关推荐