I have the following code that works perfect:
df2 = pd.DataFrame({'TEXT': ['add', 'bede', 'agdd', 'bbbb', 'aaaa'],
'PRICE': [622, 200, 100, 459, 250]})
temp=df2['TEXT']
col = 'TEXT'
conditions = [ temp.str.contains('a'), temp.str.contains('b'), temp.str.contains('c') ]
choices = [ "contains a", 'contains b', 'contains c' ]
df2["what_contains"] = np.select(conditions, choices, default=np.nan)
the thing is, the contents of conditions have to be read from a csv, which of course means that they will be strings. I have tried the following:
conditions=the_csv['cond'].apply(compile,filename='<string>',mode='eval')
but I get an error:invalid entry 0 in condlist: should be boolean ndarray
thanks!!