I have a list of skills as follows:
skills = ['Listening', 'Written_Expression','Clerical',
'Night_Vision', 'Accounting']
I have a separate list of sets, each of which contains the skills related to a particular job:
job_skills =
[{'Listening','Written_Expression','Clerical','Night_Vision'},
{'Chemistry','Written_Expression','Clerical','Listening'},
.
.
]
I want to count the frequency with which each combination of 2 unique skills is a subset of a set in job_skills and return a list of lists/sets with the combinations and frequencies as follows:
skill_pairs = [{'Listening', 'Written_Expression', 2},
{'Listening', 'Clerical', 2},
.
.
{'Night_Vision', 'Accounting', 0}]
At the moment I'm doing the following:
skill_combos = []
for idx, i in enumerate(skills):
for jdx, j in enumerate(skills[idx+1:]):
temp = []
for job in range(len(job_skills)):
temp.append(set([i,j]).issubset(job_skills[job])
skill_combos.append([i,j,sum(temp)])
This gets the job done but its slow given that I have approx half a million skill combinations. Is there a faster way of doing this? Ideally not using 3 loops.
Thanks