Python for finance (pandas, yfinance, numpy)
Intuition
Python has become the dominant language for quantitative finance, data analysis, and financial automation. Where Excel reaches its limits, with large datasets, repetitive tasks, complex statistical analysis, or automated data pipelines, Python excels. A financial analyst who can write Python code can automate hours of manual work, analyse datasets too large for Excel, and build reproducible research workflows.
You don't need to be a software engineer to use Python productively in finance. A working knowledge of three libraries, pandas for data manipulation, numpy for mathematical operations, and matplotlib/seaborn for visualisation, plus the ability to fetch data from APIs or read from files, is sufficient for most financial analysis tasks.
For Indian markets, the yfinance library provides easy access to NSE price data, and SEBI/exchange APIs provide corporate filing data. Python skills dramatically increase the scope of analysis possible within a given time budget.
Mechanics
Core libraries:
pandas: Data structures (DataFrame, Series) for structured data:
import pandas as pd
df = pd.read_csv('results.csv', parse_dates=['date'])
df['revenue_growth'] = df['revenue'].pct_change()
df.groupby('sector')['ebitda_margin'].mean()
numpy: Numerical operations:
import numpy as np
npv = np.npv(0.12, [-1000, 300, 400, 500, 400]) # Net Present Value
irr = np.irr([-1000, 300, 400, 500, 400]) # IRR
yfinance: Price and fundamental data:
import yfinance as yf
reliance = yf.Ticker("RELIANCE.NS")
history = reliance.history(period="5y")
info = reliance.info # P/E, market cap, sector
matplotlib / seaborn: Visualisation:
import matplotlib.pyplot as plt
df['revenue'].plot(kind='bar', title='Revenue Trend')
plt.tight_layout()
plt.savefig('revenue_chart.png')
Useful for finance:
- Downloading multi-year price history and computing returns
- Screener scraping with requests/BeautifulSoup (check ToS)
- Building discounted cash flow calculators
- Regression analysis (statsmodels, scikit-learn)
- Portfolio optimisation (scipy.optimize)
From the research
How Crude Oil Prices Affect India's Inflation and Current Account
India imports nearly 89% of its crude. How oil prices flow into the current account, the rupee, inflation and the budget, and what 2026 showed.
MethodologyWhat the Yield Curve Tells Us About Economic Expectations
The yield curve shows what markets expect for rates, inflation and growth. How to read its shape, what India's curve showed in October 2026, and its limits.
MethodologyHow Rupee Depreciation Affects Indian Companies Differently
A weaker rupee helps some companies and hurts others. Four kinds of currency exposure, a worked example, and what to check in the notes.
Try it yourself
Interactive exercises coming soon.
Related topics
Stay in the loop
Roughly one email per month. No spam, no upsells.