我有以下数据框
coupon_type dish_id dish_name dish_price dish_quantity
0 Rs 20 off 012 Chicken Biryani 65 2
1 Rs 20 off 013 Tava Pulav 125 3
2 Rs 20 off 014 Chicken Kadai 135 3
3 Rs 20 off 015 Total Meal 175 3
4 Rs 20 off 016 Dal Makhani 105 4
ratings reviews coupon_type user_id order_id
4 blah blah blah Rs 20 off 9 9
4 blah blah blah Rs 20 off 9 9
3 blah blah blah Rs 20 off 9 9
4 blah blah blah Rs 20 off 9 9
4 blah blah blah Rs 20 off 9 9
我在菜名上做小组
df_dish_name = df_final.groupby('dish_name')
然后我在groupby上执行一些比率操作。这给了我一个熊猫系列。
dish_name
Dal Makhani 18.75
Name: dish_quantity, dtype: float64
现在我想将新的字符串'AP'添加到相应的菜肴名称Dal Makhani ..
我这样做..
df_final['Flag'] = np.where(df_final['dish_name'].isin(dish1.index),'AP')
但它没有将相应的值设置为'AP'。