Skip to content

Commit

Permalink
Merge pull request #10 from Wambaforestin/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
Wambaforestin authored Oct 28, 2024
2 parents f8dd2ed + 7195295 commit 93b5c01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Binary file modified Personal_Finance_Tracker/__pycache__/data_entry.cpython-312.pyc
Binary file not shown.
13 changes: 7 additions & 6 deletions Personal_Finance_Tracker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def get_transactions(cls, start_date, end_date):
"date": lambda x: x.strftime("%d-%m-%Y")
}))

total_income = filtered_df[filtered_df["category"] == "Income"]["amount"].sum()
total_expense = filtered_df[filtered_df["category"] == "Expense"]["amount"].sum()
total_income = filtered_df[filtered_df["category"] == "Income"]["amount"].fillna(0).sum()
total_expense = filtered_df[filtered_df["category"] == "Expense"]["amount"].fillna(0).sum()

print("\n Summary")
print(f"Total Income: €{total_income: .2f}")
Expand All @@ -70,12 +70,13 @@ def get_transactions(cls, start_date, end_date):
return filtered_df

@classmethod
def plot_transactions(cls,df):
def plot_transactions(cls, df):
df["date"] = pd.to_datetime(df["date"], format="%d-%m-%Y")
df.sort_values("date", inplace=True)
df.set_index("date", inplace=True)

income_df = df[df["category"] == "Income"].resample("D").sum().reindex(df.index, fill_value=0) #Resampling the data to daily frequency
expense_df = df[df["category"] == "Expense"].resample("D").sum().reindex(df.index, fill_value=0) #Resampling the data to daily frequency
income_df = df[df["category"] == "Income"].resample("D").sum().reindex(df.index, fill_value=0)
expense_df = df[df["category"] == "Expense"].resample("D").sum().reindex(df.index, fill_value=0)

plt.figure(figsize=(10, 6))
plt.plot(income_df.index, income_df["amount"], label="Income", color="green")
Expand All @@ -85,8 +86,8 @@ def plot_transactions(cls,df):
plt.title("Income vs Expense")
plt.legend()
plt.grid(True)
plt.tight_layout() # Ensure everything fits without overlap
plt.show()


def add():
CSV.initialize()
Expand Down

0 comments on commit 93b5c01

Please sign in to comment.