engralimalik commited on
Commit
0a44aa0
·
verified ·
1 Parent(s): 3c13623

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
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
- fig2 = px.line(monthly_expenses_df, x='Month', y='Amount', title="Monthly Expenses", labels={"Month": "Month", "Amount": "Amount ($)"})
77
- st.plotly_chart(fig2)
 
 
 
78
 
79
  # 3. Monthly Spending vs Budget (Bar Chart)
80
- monthly_expenses_df = pd.DataFrame({
81
- 'Actual': monthly_expenses,
82
- 'Budget': [sum(budgets.values())] * len(monthly_expenses) # Same budget for simplicity
83
- })
84
-
85
- fig3 = monthly_expenses_df.plot(kind='bar', figsize=(10, 6))
86
- st.pyplot(fig3)
 
 
 
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.")