I don't understand why I'm getting this error. I think maybe I'm not comparing single values or I'm not sure.
Here is the code:
v_1 = meals[meals['index'] == episode_run[-1]]['value_ser1']
v_2 = meals[meals['index'] == episode_run[-1]]['value_ser2']
if v_1 >= v_2:
toBeServed = 1
else:
toBeServed = 2
It gives the error when comparing between v_1
and v_2
.
error Message:
File "C:\Users\pc\Pycharm Projects\MealPlanner_Attempt 2\venv\lib\site-packages\pandas\core\generic.py", line 1479, in __nonzero__
f"The truth value of a {type(self).__name__} is ambiguous. "
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
as for values to reproduce the error, the values are usually extracted from a dataframe from the dataset I have but the following are an example value of v_1 and v_2 when printing
959 1.041667
Name: value_ser1, dtype: float64
959 1.041667
Name: value_ser2, dtype: float64
index,name,type,breakfast,main_dish,calories,carbs,fats,proteins,saturated_fats, sugar,value_ser1,value_ser2,avg_val
68, Apple, Appetizers, 1, 0, 94.64, 25.134200000000003, 0.3094, 0.4732, 0.0546, 10.39, 0.5374056773266259, 0.5374056773266259, 0.5374056773266259
71,Cinnamon Apple Bites,Appetizers,1,0,80.50080000000001,21.60213,0.2272200000000001,0.4869000000000001,0.03246,10.04,0.29511318720804885,0.29511318720804885,0.29511318720804885
77,Egyptian Feta Cheese Omelet Roll,Appetizers,1,1,244.889464,1.7642079999999998,19.580224,14.710016,5.764735999999999,0.87,0.10807731464846088,0.10807731464846088,0.10807731464846088
120,Cheese On Toast,Appetizers,1,0,257.03282,18.276632,15.051344000000002,12.292874000000001,8.218826,3.84,0.0561863696251048,0.0561863696251048,0.0561863696251048
122,Brie cheese on bread,Appetizers,1,0,204.125775,18.027295,9.59421,11.405565,5.29473,4.16,0.15411426518145885,0.15411426518145885,0.15411426518145885
130,Guacamole on Tostada,Appetizers,1,0,192.059415,18.564195,13.523130000000002,2.85603,2.3226750000000003,1.64,0.001221703197987783,0.001221703197987783,0.001221703197987783
134,Camembert on Garlic Bread,Appetizers,1,0,362.317415,53.472865000000006,9.318145,16.677265,4.8549750000000005,3.34,0.021048928015331172,0.021048928015331172,0.021048928015331172
138,Avocado with Cottage Cheese and Balsamic Glaze,Appetizers,1,0,203.68012500000003,14.919375,15.369000000000002,4.9731250000000005,2.4933750000000003,1.32,0.0005030542579949693,0.0005030542579949693,0.0005030542579949693
144,Date Energy Bars,Appetizers,1,0,188.47853999999998,33.950880000000005,6.451919999999999,2.9754,1.26324,48.31,0.00535393460294646,0.00535393460294646,0.00535393460294646
153,Egg and Asparagus Scramble,Appetizers,1,1,193.6995,5.7597,14.32035,11.00655,2.899575,1.64,0.04967960234758653,0.04967960234758653,0.04967960234758653
# read it in with
df = pd.read_clipboard(sep=',')