Using Python to automate your Personal Finance Pt.1

Gabriel Shoaib
3 min readAug 23, 2020

Part 1. Proof of Concept

Part 2. Storing Data Better (gspread) CLICK HERE

Part 3. Plaid API

Part 4. NLP Classification

Part 5. Front End Design

If you’re ever looked back at your bank statement and thought, “Yo, where’d my money go?”, then using Pandas to track your transactions can help you out.

Power of Pandas

Using excel is the most straight forward way to create a budget, and I recommend starting with excel to get a good grasp of your money layout. A step to advance your excel budget template is to look into Pandas. Pandas can be used to automate the excel analysis that is done when looking at banking transactions. Instead of running macros where repeated steps are conducted, utilizing the power of Pandas allows you to speed through all the data manipulation to skip straight to the output in a short amount of time.

I’ll be using transaction exports from the Chase website along with Pandas to get a quick summary of my personal banking expenses.

Prepare your Data Files

1.Download your Banking Transactions for any given period of time and import them into your code editor. Note that File 1 refers to Credit Card data and File 2/3 refers to Debit Card data. In my exercise, I do not have any Checks so I manually removed the “Checks Slips” column from the excel sheet. I advise you do the same.

Modify Date Data

2. Once the data is loaded, we’ll need to make some necessary modifications regarding the Date columns. In the Credit Card data modify the “Transaction Date” and “Post Date” and in the Debit Card data modify the “Posting Date”. I’m not going to be using the “Post Date” column but I modified it in order to be consistent. Additionally, we’re going to be creating a new column that’ll take the date that the transaction took place and stores the “Month Year”. Refer to column 5,7, and 9.

Align the data

3. Last modifications to the data is to rename the “Transaction Date” from the credit card data so that it matches the date column in the Debit card data. Once those are synced up, we’ll be dropping all the columns we’re not using.

Concat away

4. Now we need to clean up the data to focus on the information that’s relevant to expenses. Concat all the data into a single source and drop all the non-expenses related transactions from the “Type” column.

Fin

5. Lastly we’ll use a group by to get an aggregate of the transaction expenses took place and visualize the output!

Understanding your last months expenses is a huge leap from occasionally scanning over your transactions and measuring where you stand. I have some ideas on how to further this project but I would love to hear your thoughts, ideas and feedback!

github: https://github.com/gshoaib/MonthlyExpense

--

--

Gabriel Shoaib

Data guy but with an interest in Technology, Marketing, Startups and some outdoor stuff.