Update app.py
Browse files
app.py
CHANGED
@@ -73,14 +73,19 @@ if uploaded_file:
|
|
73 |
|
74 |
# Convert monthly_expenses into DataFrame for correct plotting
|
75 |
monthly_expenses_df = monthly_expenses.reset_index()
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
78 |
|
79 |
# 3. Monthly Spending vs Budget (Bar Chart)
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
|
|
|
73 |
|
74 |
# Convert monthly_expenses into DataFrame for correct plotting
|
75 |
monthly_expenses_df = monthly_expenses.reset_index()
|
76 |
+
if not monthly_expenses_df.empty:
|
77 |
+
fig2 = px.line(monthly_expenses_df, x='Month', y='Amount', title="Monthly Expenses", labels={"Month": "Month", "Amount": "Amount ($)"})
|
78 |
+
st.plotly_chart(fig2)
|
79 |
+
else:
|
80 |
+
st.write("No data to display for the selected date range.")
|
81 |
|
82 |
# 3. Monthly Spending vs Budget (Bar Chart)
|
83 |
+
if not monthly_expenses_df.empty:
|
84 |
+
monthly_expenses_df = pd.DataFrame({
|
85 |
+
'Actual': monthly_expenses,
|
86 |
+
'Budget': [sum(budgets.values())] * len(monthly_expenses) # Same budget for simplicity
|
87 |
+
})
|
88 |
+
fig3 = monthly_expenses_df.plot(kind='bar', figsize=(10, 6))
|
89 |
+
st.pyplot(fig3)
|
90 |
+
else:
|
91 |
+
st.write("No data to display for the selected date range.")
|