我正在试图清除原始联系人信息的数据框。原始数据给出了一个人的头衔,根据头衔我需要确定资历级别。如果标题与dictionary键部分匹配,我需要将该键的值附加到一个新列表中。本质上,我需要遍历列表中的每个标题,查看是否有与任何字典键的部分匹配,并获取相应的字典值,然后将该值附加到新列表中。我尝试了多种形式的for循环和列表理解,但没有成功
下面是列表和命令的示例:
title = ['CEO', 'CFO', 'Financial Analyst', 'Associate', 'Tax Manager', 'Audit Manager']
seniority_dict = {'CEO':'Exec', 'CFO':'Exec', 'Manager':'Manager', 'Analyst':'Associate', 'Associate':'Associate'}
下面是上面列表中相应值的资历
seniority = ['Exec', 'Exec', 'Associate', 'Associate', 'Manager', 'Manager']
如果你没有钥匙不在标题里
相关问题 更多 >
编程相关推荐