Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -99,20 +99,6 @@ else:
|
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
-
# PART 3
|
| 103 |
-
# Convert the DataFrame stored in session_state to a CSV format, without the index column.
|
| 104 |
-
csv = st.session_state['expenses'].to_csv(index=False).encode("utf-8")
|
| 105 |
-
|
| 106 |
-
# Download button for user to download expenses as a CSV file
|
| 107 |
-
st.download_button(
|
| 108 |
-
label = "Export Expenses as CSV", # Text on the button
|
| 109 |
-
data = csv, # The data to download (csv from above)
|
| 110 |
-
file_name = "expenses.csv", # Name of downloaded file
|
| 111 |
-
mime = "text/csv" # Specify the file type (MIME type) as CSV
|
| 112 |
-
)
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
|
| 117 |
|
| 118 |
# PART 4
|
|
@@ -196,24 +182,6 @@ if viz_button:
|
|
| 196 |
st.pyplot(fig)
|
| 197 |
|
| 198 |
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
# Display expenses over time
|
| 202 |
-
st.subheader("Expenses Over Time")
|
| 203 |
-
|
| 204 |
-
# Group by 'Category' and sum the 'Amount'
|
| 205 |
-
date_group = st.session_state['expenses'].groupby('Date')['Amount'].sum().reset_index()
|
| 206 |
-
|
| 207 |
-
# Ensure 'Date' column is datetime
|
| 208 |
-
date_group['Date'] = pd.to_datetime(date_group['Date'])
|
| 209 |
-
|
| 210 |
-
# Sort data by 'Date'
|
| 211 |
-
date_group = date_group.sort_values(by='Date')
|
| 212 |
-
|
| 213 |
-
date_group.set_index('Date', inplace=True)
|
| 214 |
-
|
| 215 |
-
st.line_chart(date_group['Amount'])
|
| 216 |
-
|
| 217 |
else:
|
| 218 |
# Message displayed when there is no data to visualise
|
| 219 |
st.write("No data to visualise.")
|
|
|
|
| 99 |
|
| 100 |
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
|
| 104 |
# PART 4
|
|
|
|
| 182 |
st.pyplot(fig)
|
| 183 |
|
| 184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
else:
|
| 186 |
# Message displayed when there is no data to visualise
|
| 187 |
st.write("No data to visualise.")
|