I am very new to Python so apologies for this basic question. I am trying to match columns of keywords with a list of text. If the keyword(s) can be found in the text, these should be appended to the spreadsheet which currently ends at the 'Engagement' column.
I currently get the following error message in the 2nd line of the 'for-loop': TypeError: 'in ' requires string as left operand, not float
What's wrong with my code and how should I correct it? Thank you.
df_rawdata = pd.read_excel (r'test.xlsx', sheet_name ='rawdata')
my_rawdatalist = df_rawdata['Text'].tolist()
df_all_words = pd.read_excel (r'test.xlsx', sheet_name ='pet_dict')
keywords_list = set(df_all_words['Animals'].tolist()+df_all_words['Cities'].tolist())
matchlist = []
for rawdata in my_rawdatalist:
matches = [keyword for keyword in keywords_list if keyword in rawdata]
matchlist.append("|".join(matches))
print(matchlist)


my_rawdatalisthave more than onekeywordin it and if so, what should happen?