I have a categorization problem. The categorizing rule is:
If
Storage Condition == 'refrigerate'
and100 < profit Per Unit < 150
andInventory Qty <20
is given, restock Action = 'Hold Current stock level'
else restock Action = 'On Sale'
.
Here's the dataset I need to run the rules on:
ID, Fruit, Stroage Condition, Profit Per Unit, In Season or Not, Inventory Qty, Restock Action
1, Apple, room temperature, 20, Yes, 200,
2, Banana, room temperature, 65, Yes, 30,
3, Pear, refrigerate, 60, Yes, 180,
4, Strawberry, refrigerate, 185, No, 70,
5, Watermelon, room temperature, 8, No, 90,
6, Mango, Other, 20, No, 100,
7, DragonFruit, Other, 65, No, 105,
Code I have tried:
for i in range(len(df['ID'])):
if df['Storage Condition'][i] == 'refrigerate' and df['Profit Per Unit'][i] >100 and df['Profit Per Unit'][i] <150 and df['Inventory Qty'][i] <20:
df['restock action'] = 'Hold Current stock level'
But I got this error message:
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Can any one please help?