Update app.py
Browse files
app.py
CHANGED
@@ -26,19 +26,4 @@ def process_expenses(file):
|
|
26 |
df['Category'] = categorize_transaction_batch(df['Description'].tolist())
|
27 |
|
28 |
# Create visualizations:
|
29 |
-
# 1. Pie chart for Category-wise
|
30 |
-
category_spending = df.groupby("Category")['Amount'].sum()
|
31 |
-
fig1 = px.pie(category_spending, names=category_spending.index, values=category_spending.values, title="Category-wise Spending")
|
32 |
-
|
33 |
-
# 2. Monthly spending trends (Line plot)
|
34 |
-
df['Date'] = pd.to_datetime(df['Date'])
|
35 |
-
df['Month'] = df['Date'].dt.to_period('M')
|
36 |
-
monthly_spending = df.groupby('Month')['Amount'].sum()
|
37 |
-
fig2 = px.line(monthly_spending, x=monthly_spending.index, y=monthly_spending.values, title="Monthly Spending Trends")
|
38 |
-
|
39 |
-
# 3. Budget vs Actual Spending (Bar chart)
|
40 |
-
category_list = df['Category'].unique()
|
41 |
-
budget_dict = {category: 500 for category in category_list} # Default budget is 500 for each category
|
42 |
-
budget_spending = {category: [budget_dict[category], category_spending.get(category, 0)] for category in category_list}
|
43 |
-
budget_df = pd.DataFrame(budget_spending, index=["Budget", "Actual"]).T
|
44 |
-
fig3 = px.bar(budget_df, x=budget_df.index, y=["Budget", "Actual"], title=
|
|
|
26 |
df['Category'] = categorize_transaction_batch(df['Description'].tolist())
|
27 |
|
28 |
# Create visualizations:
|
29 |
+
# 1. Pie chart for Category-wise spendin
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|