- I have a value in my df
NEFT fm Principal Focused Multi
. - I have a list of words containing keywords like
NEFT, neft
. So, if the above string of DF containsNEFT
word, I want to add a new column and mark it asTrue
. - Sample Input
- I was trying
for index, row in ldf_first_page.iterrows():
row.str.lower().isin(llst_transaction_keywords)
- But it is trying to check the exact keyword, and I am looking for something like
contains
.
CodePudding user response:
Pardon me but I'm a beginner, have you perhaps tried using any()? I think this function matches what you need.
for index, row in ldf_first_page.iterrows(): row.str.lower().any(llst_transaction_keywords)
CodePudding user response:
Try:
for index, row in ldf_first_page.iterrows():
if llst_transaction_keywords in row:
return True