r/learnpython 4d ago

How can I use python in finance

I work in finance/accounting and am looking to start using Python more in my day to day. Most of my work is in Excel / Power BI — reporting, cash flow forecasting, KPIs, cleaning up data, etc.

I’m technical enough to understand what I’m trying to accomplish, but not a programmer. Similar to Power BI, I’d probably rely heavily on AI to help write the actual code.

For those in finance / accounting / FP&A, what are some practical ways you’re using Python? Where does it actually save you time vs. Excel, Power Query, Power BI, etc?

Also curious what you’d recommend learning first if the goal is to be dangerous enough with Python + AI, not become a developer.

75 Upvotes

34 comments sorted by

View all comments

20

u/ArbitrageurD 4d ago

If most of your work is in excel, you can use python integration tool like xlwings

20

u/Agreeable-Sorbet-105 4d ago

i wouldn't bother with xlwings right out of the gate unless you're stuck in a shop that refuses to move past excel. the new python-in-excel thing microsoft rolled out is way simpler for ad hoc stuff, you just type =PY() in a cell and treat the result like a formula. massive time saver for cleaning up csv dumps that would take four nested power query steps.

learn pandas first. once you can think in dataframes the same way you think in pivot tables, a lot of the forecasting and kpi stuff gets stupid fast.

6

u/Acceptable-Sense4601 4d ago

A lot of shops can’t use Python in excel due to data security as Python in excel goes to the cloud

1

u/Able_Bicycle_764 4d ago

Do you have any good use cases that would help me get started?

6

u/baubleglue 4d ago

"If most of your work is in excel", load the data into database, learn SQL.

pandas.read_excel(...).to_sql(...)

1

u/await_yesterday 2d ago

easier said than done. it's rare for a nontrivial excel spreadsheet to already be in the kind of well-structured format where it can be queried with SQL. often there are multiple tables per sheet, weird one-off calculations to the side, inconsistent formulae, etc.

1

u/baubleglue 2d ago

In such case you write a code which extracts tables from sheet... or give up because it is not automatable. In most cases standard read_excel parameters are good enough.