matesoft commited on
Commit
88b8da4
Β·
verified Β·
1 Parent(s): 21d76cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -17,17 +17,17 @@ def bmi(name, height, weight, feeling):
17
  output_str = f"Hello πŸ‘‹ {name}...\nYour BMI is {bmi_value:.2f}"
18
  feeling_msg = "You're feeling happy today! 😊" if feeling == "Yes" else "Hope you feel better soon! 🌈"
19
 
20
- # Append new entry
21
- new_entry = {
22
  "Name": name,
23
  "Height": height,
24
  "Weight": weight,
25
  "BMI": round(bmi_value, 2),
26
  "Feeling": feeling
27
- }
28
 
29
  global df_history
30
- df_history = df_history._append(new_entry, ignore_index=True)
31
  df_history.to_csv(DATA_FILE, index=False)
32
 
33
  return output_str, result_emoticon, feeling_msg, df_history
@@ -51,8 +51,7 @@ interface = gr.Interface(
51
  ["guro", 1.75, 70, "Yes"],
52
  ["levan", 1.69, 73, "Yes"]
53
  ],
54
-
55
- theme = gr.themes.Soft(),
56
  title="BMI Calculator with Emotions 😊",
57
  description="Your BMI is calculated and saved with your name and mood. Try an example or input your own info!"
58
  )
 
17
  output_str = f"Hello πŸ‘‹ {name}...\nYour BMI is {bmi_value:.2f}"
18
  feeling_msg = "You're feeling happy today! 😊" if feeling == "Yes" else "Hope you feel better soon! 🌈"
19
 
20
+ # Append new entry using concat (instead of deprecated _append)
21
+ new_entry = pd.DataFrame([{
22
  "Name": name,
23
  "Height": height,
24
  "Weight": weight,
25
  "BMI": round(bmi_value, 2),
26
  "Feeling": feeling
27
+ }])
28
 
29
  global df_history
30
+ df_history = pd.concat([df_history, new_entry], ignore_index=True)
31
  df_history.to_csv(DATA_FILE, index=False)
32
 
33
  return output_str, result_emoticon, feeling_msg, df_history
 
51
  ["guro", 1.75, 70, "Yes"],
52
  ["levan", 1.69, 73, "Yes"]
53
  ],
54
+ theme=gr.themes.Soft(),
 
55
  title="BMI Calculator with Emotions 😊",
56
  description="Your BMI is calculated and saved with your name and mood. Try an example or input your own info!"
57
  )