Update app.py
Browse files
app.py
CHANGED
|
@@ -17,6 +17,10 @@ def analyze_energy_usage(data, household_id=None):
|
|
| 17 |
else:
|
| 18 |
household_data = data
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# Aggregate data
|
| 21 |
total_usage = household_data["Energy Usage (kWh)"].sum()
|
| 22 |
avg_cost = household_data["Cost"].mean()
|
|
@@ -66,8 +70,12 @@ if uploaded_file:
|
|
| 66 |
|
| 67 |
# Analyze Data
|
| 68 |
if st.button("Analyze Energy Usage"):
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
st.subheader("Energy Usage Summary")
|
| 72 |
st.text(report_summary)
|
| 73 |
|
|
|
|
| 17 |
else:
|
| 18 |
household_data = data
|
| 19 |
|
| 20 |
+
# Check if the filtered data is empty
|
| 21 |
+
if household_data.empty:
|
| 22 |
+
return "No data available for the specified Household ID.", None
|
| 23 |
+
|
| 24 |
# Aggregate data
|
| 25 |
total_usage = household_data["Energy Usage (kWh)"].sum()
|
| 26 |
avg_cost = household_data["Cost"].mean()
|
|
|
|
| 70 |
|
| 71 |
# Analyze Data
|
| 72 |
if st.button("Analyze Energy Usage"):
|
| 73 |
+
with st.spinner("Analyzing..."):
|
| 74 |
+
report_summary, filtered_data = analyze_energy_usage(data, household_id)
|
| 75 |
+
|
| 76 |
+
if filtered_data is None:
|
| 77 |
+
st.warning(report_summary) # Display message for no data
|
| 78 |
+
else:
|
| 79 |
st.subheader("Energy Usage Summary")
|
| 80 |
st.text(report_summary)
|
| 81 |
|