So the problem I am facing that I am looking for a solution to do something like this: (general example)
def categotizer(value):
toys = ['ball', 'bear', 'lego']
food = ['pizza', 'ice-cream', 'cake']
if value in toys:
return 'toys'
if value in food:
return 'food'
else:
return 'empty'
df['purchases_category'] = df['purchases'].apply(categorizer)
On a column which looks like the first one with result as the second column: Table
In this exact method I am getting new column filled with 'empty' values though I totally have examples from the lists. How could this possibly be fixed?
Thanks.