I am trying to make a column of a dataframe to matches (if any) to a list. A custom function called return hits has been created to that effect.
def returnhits(a_list, long_string):
matches =[]
for match in a_list:
if any(word in long_string.split() for match in a_list):
matches.append(match)
return ' , '.join(matches)
qualification_list = ('Professional Certificate', 'NiTEC ', "Bachelor's Degree", 'Diploma', 'Advanced/Higher/Graduate Diploma', 'Post Graduate Diploma' , 'Professional Degree', "Master's Degree" , 'Doctorate (PhD)')
However I am unable to produce the desired results.
df['Qualifications'] = df['Other information'].apply(lambda x : returnhits(qualification_list, x))
Ideally if there is a match in the text it will return say NiTEC ,Professional Degree