Bit of a beginner question here; I currently have a pandas df with one column containing various different strings. I have some more columns which are currently empty. Example of first few rows below;
Risk,Cost,Productivity,Security
"Unforeseen cost due to CCTV failures",,,
"Unexpected drop in Productivity",,,
I've also created a set of lists as follows;
Cost = ['Cost']
Productivity = ['Productivity']
Security = ['Security','CCTV','Camera']
Essentially what I want to do is I want to go through each column and check whether the string in the "Risk" column on the same row contains a substring that matches one of the strings in the list. The ideal output would be as follows;
Risk,Cost,Productivity,Security
"Unforeseen cost due to security issues",TRUE,FALSE,TRUE
"Unexpected drop in Productivity",FALSE,TRUE,FALSE
I've tried a few different methods so far, such as
any(Cost in Risk for Cost in Costs)
However, I'm not sure if there's a way to avoid the any() function being case sensitive, and I'm not sure how to apply this to a whole column.. I did try
df['Cost'] = any(Cost in df['Risk'] for Cost in Costs)
but that returned a column full of "FALSE". Any nudge in the right direction would be hugely appreciated! Thank you