I am trying to write a function that will classify goods in a given dataset (in a very straightforward way, i know).
It looks like:
def classifier(x):
if ('smth' or 'smth' or 'smth') in x:
return 'class1'
elif ('smth' or 'smth' or 'smth') in x:
return 'class2'
So, the problem is that some conditions do not work. When I try to check conditions separately - everything works. But in the function something goes wrong.
I use thing function with a pandas apply
-method:
data['classes'] = data['subj'].apply(lambda x: classifier(x))