Update app.py
Browse files
app.py
CHANGED
|
@@ -87,36 +87,39 @@ 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 |
-
menu_df = pd.DataFrame(menu)
|
| 91 |
-
|
| 92 |
# Function to assign weekdays to dishes
|
| 93 |
def assign_weekdays(menu):
|
| 94 |
weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
|
| 95 |
-
|
| 96 |
menu_with_weekdays = []
|
|
|
|
|
|
|
| 97 |
for i, dish in enumerate(menu):
|
| 98 |
if isinstance(dish, dict):
|
| 99 |
-
|
| 100 |
else:
|
| 101 |
-
|
| 102 |
|
| 103 |
-
dish_with_day
|
| 104 |
menu_with_weekdays.append(dish_with_day)
|
| 105 |
|
| 106 |
-
return
|
| 107 |
|
| 108 |
-
|
| 109 |
-
dinner_menu = menu_df.iloc[len(menu_df)//2:]
|
| 110 |
|
| 111 |
-
|
|
|
|
| 112 |
|
| 113 |
-
lunch_menu =
|
| 114 |
-
dinner_menu =
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
-
return
|
| 120 |
|
| 121 |
# Function to calculate BMI and recommend diet
|
| 122 |
def bmi_insights(weight, height_cm):
|
|
@@ -179,10 +182,12 @@ def main():
|
|
| 179 |
|
| 180 |
st.header("Weekly Menu")
|
| 181 |
st.subheader("Lunch Menu")
|
| 182 |
-
|
|
|
|
| 183 |
|
| 184 |
st.subheader("Dinner Menu")
|
| 185 |
-
|
|
|
|
| 186 |
|
| 187 |
st.subheader(f"Total Expenditure for the Week: PKR {total_cost}")
|
| 188 |
|
|
|
|
| 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 |
+
# Apply weekdays to the menu
|
| 110 |
+
full_menu_with_weekdays = assign_weekdays(menu_df)
|
| 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 |
+
return lunch_menu_df, dinner_menu_df, total_cost, shopping_list
|
| 123 |
|
| 124 |
# Function to calculate BMI and recommend diet
|
| 125 |
def bmi_insights(weight, height_cm):
|
|
|
|
| 182 |
|
| 183 |
st.header("Weekly Menu")
|
| 184 |
st.subheader("Lunch Menu")
|
| 185 |
+
for index, row in lunch_menu.iterrows():
|
| 186 |
+
st.write(f"{row['Weekday']}: {row['Name']}")
|
| 187 |
|
| 188 |
st.subheader("Dinner Menu")
|
| 189 |
+
for index, row in dinner_menu.iterrows():
|
| 190 |
+
st.write(f"{row['Weekday']}: {row['Name']}")
|
| 191 |
|
| 192 |
st.subheader(f"Total Expenditure for the Week: PKR {total_cost}")
|
| 193 |
|