Update app.py
Browse files
app.py
CHANGED
|
@@ -87,39 +87,17 @@ def generate_menu(data, season, outings, dietary_restrictions, bmi, pantry_ingre
|
|
| 87 |
side_dishes = data[data['Course'] == 'Side Dish'].sample(2).to_dict('records')
|
| 88 |
menu.extend(side_dishes)
|
| 89 |
|
| 90 |
-
# Function to assign weekdays to dishes
|
| 91 |
-
def assign_weekdays(menu):
|
| 92 |
-
weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
|
| 93 |
-
menu_with_weekdays = []
|
| 94 |
-
|
| 95 |
-
# Create menu for the week with each dish assigned to a weekday
|
| 96 |
-
for i, dish in enumerate(menu):
|
| 97 |
-
if isinstance(dish, dict):
|
| 98 |
-
dish_name = dish["Name"]
|
| 99 |
-
else:
|
| 100 |
-
dish_name = dish # If it's just a string, take the name directly
|
| 101 |
-
|
| 102 |
-
dish_with_day = {"Name": dish_name, "Weekday": weekdays[i % 7]}
|
| 103 |
-
menu_with_weekdays.append(dish_with_day)
|
| 104 |
-
|
| 105 |
-
return menu_with_weekdays
|
| 106 |
-
|
| 107 |
menu_df = pd.DataFrame(menu)
|
| 108 |
|
| 109 |
-
|
| 110 |
-
|
| 111 |
|
| 112 |
-
lunch_menu = full_menu_with_weekdays[:len(full_menu_with_weekdays)//2]
|
| 113 |
-
dinner_menu = full_menu_with_weekdays[len(full_menu_with_weekdays)//2:]
|
| 114 |
-
|
| 115 |
-
# Convert to DataFrame for display
|
| 116 |
-
lunch_menu_df = pd.DataFrame(lunch_menu)
|
| 117 |
-
dinner_menu_df = pd.DataFrame(dinner_menu)
|
| 118 |
-
|
| 119 |
-
# Calculate total cost (assuming it's available in the data)
|
| 120 |
total_cost = menu_df["Cost per 4 persons"].sum()
|
| 121 |
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
# Function to calculate BMI and recommend diet
|
| 125 |
def bmi_insights(weight, height_cm):
|
|
@@ -182,12 +160,10 @@ def main():
|
|
| 182 |
|
| 183 |
st.header("Weekly Menu")
|
| 184 |
st.subheader("Lunch Menu")
|
| 185 |
-
|
| 186 |
-
st.write(f"{row['Weekday']}: {row['Name']}")
|
| 187 |
|
| 188 |
st.subheader("Dinner Menu")
|
| 189 |
-
|
| 190 |
-
st.write(f"{row['Weekday']}: {row['Name']}")
|
| 191 |
|
| 192 |
st.subheader(f"Total Expenditure for the Week: PKR {total_cost}")
|
| 193 |
|
|
|
|
| 87 |
side_dishes = data[data['Course'] == 'Side Dish'].sample(2).to_dict('records')
|
| 88 |
menu.extend(side_dishes)
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
menu_df = pd.DataFrame(menu)
|
| 91 |
|
| 92 |
+
lunch_menu = menu_df.iloc[:len(menu_df)//2]
|
| 93 |
+
dinner_menu = menu_df.iloc[len(menu_df)//2:]
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
total_cost = menu_df["Cost per 4 persons"].sum()
|
| 96 |
|
| 97 |
+
lunch_menu = lunch_menu[["Name"]]
|
| 98 |
+
dinner_menu = dinner_menu[["Name"]]
|
| 99 |
+
|
| 100 |
+
return lunch_menu, dinner_menu, total_cost, shopping_list
|
| 101 |
|
| 102 |
# Function to calculate BMI and recommend diet
|
| 103 |
def bmi_insights(weight, height_cm):
|
|
|
|
| 160 |
|
| 161 |
st.header("Weekly Menu")
|
| 162 |
st.subheader("Lunch Menu")
|
| 163 |
+
st.write(lunch_menu)
|
|
|
|
| 164 |
|
| 165 |
st.subheader("Dinner Menu")
|
| 166 |
+
st.write(dinner_menu)
|
|
|
|
| 167 |
|
| 168 |
st.subheader(f"Total Expenditure for the Week: PKR {total_cost}")
|
| 169 |
|