Portfolio / Self-learning budget categorizer
Self-learning budget categorizer
Load a month of bank transactions. Merchants it already knows get sorted instantly. New ones get asked about once, saved to the dictionary, and never asked about again. Load the next month and watch it get smarter.
Load January. I’ll sort what I know and ask about the rest.
This one’s personal: I built it for my own money.
Every month meant downloading statements and sorting transactions by hand, and banks describe the same coffee shop five different ways. So I built a Python app in Streamlit with a standard template for every statement, and a categorizer that remembers. Each new merchant gets a category once; after that, it sorts itself.
A real project I built for myself. The transactions shown here are sample data.
Before
- Downloading statements and sorting every line by hand
- "SQ *BLUE BOTTLE 0412" and "BLUE BOTTLE COFFEE" treated as different places
- The same categorizing work every single month
- Spending totals that were never quite right
After
- One template every statement goes into
- Known merchants sorted automatically
- Each new merchant taught once, then remembered
- Less work every month as the dictionary grows
Try it yourself
| Date | Description from the bank | Amount | Category |
|---|
It gets smarter every month
Share of each month's transactions sorted with no help.
Spending by category
Shows up once transactions have categories.
The real app runs in Python with Streamlit. This browser version uses sample transactions so you can try it. This is a tool for organizing your own numbers, not financial advice.
What this could be worth to you
The sorting work shrinks every month, and knowing where money goes is how you keep more of it.
Example numbers to start you off. Move the sliders to match your business. These are estimates, not a guarantee or financial advice; your results depend on your situation.
The problem
Bank exports describe merchants in messy, inconsistent ways, so categorizing spending means doing the same sorting by hand every month.
The solution
A Streamlit app that loads each statement into one standard template, cleans up merchant names, and looks them up in a growing dictionary. Anything it doesn’t recognize goes into a short "needs a category" list; once you answer, the dictionary learns it for good.
How it's built
- LoadDownload statements and drop them into the app.
- StandardizeEvery bank’s format goes into one template.
- CleanStrip codes like "SQ *" and store numbers from merchant names.
- Look upMatch merchants against the dictionary.
- LearnNew merchants get one question, then get saved.
The heart of it is a dictionary that grows:
import re, json
def merchant_key(desc):
desc = re.sub(r"^(SQ \*|TST\* ?)", "", desc.upper())
return re.sub(r"[#*]\S*|\d+", " ", desc).split()[:2]
def categorize(df, dictionary):
df["key"] = df["Description"].map(lambda d: " ".join(merchant_key(d)))
df["Category"] = df["key"].map(dictionary)
return df, df[df["Category"].isna()] # the "needs a category" list
# after the user answers in Streamlit:
dictionary.update(new_answers)
json.dump(dictionary, open("merchants.json", "w"))
What it makes possible
- Monthly budgeting takes minutes instead of an evening
- Totals by category you can actually trust
- The more you use it, the less work it needs
Skills shown
More to try
Want a tool like this for your business?
The same idea works for expense reports, vendor bills or sales data.
Starting prices are for smaller projects. Bigger or more complex jobs are priced by scope: how much there is and how long it takes.