I have a dataframe like as shown below
df = pd.DataFrame({'text': ["Hi how","I am fine","Ila say Hi","hello"],
'tokens':["test","correct","Tim",np.nan],
'labels':['A','B','C','D']})
Instead of multiple np.where conditions, I would like to use Or or | operator to check for multiple values in np.where condition like below
df['labels'] = np.where(df['tokens'] == ('test'|'correct'|is.na()),'new_label',df['labels'])
However, this results in an error
TypeError: unsupported operand type(s) for |: 'str' and 'str'
I expect my output to be like as shown below. How can I do this efficiently for big data with million of records?
