Contents
Contents
Tap any chapter to start reading. Each chapter has a companion slide deck at statpython.pages.dev.
Chapter 0 Basics of PythonPython as a calculator, numbers, strings, lists, tuples, sets, dictionaries, control flow, comprehensions, functions, error handling.
Chapter 1 Data Structures and Methods of Seriespandas Series end to end: operators, aggregation, apply/where, missing data, sorting, clipping, ranking, binning, indexing, dates, rolling windows, resampling, plotting.
Chapter 2 DataFramesDataFrame methods end to end: axes and alignment, agg and apply, missing and duplicated values, filtering, groupby, pivot, melt, stack, merging and concatenation, and the modern method-chaining style.
Chapter 3 Reshaping StatisticsFrom averages to distributions: empirical and theoretical distributions, bootstrap confidence intervals and hypothesis tests, experimental design with A/B tests and bandits, linear and nonlinear association, and extreme value theory for the tails.
Chapter 4 Statistical Predictive ModelsCredit-risk case (default, EAD, LGD): feature engineering, multiple regression, model selection, inference, trees and boosting, logistic classification, and why prediction is not causation, plus attention-based cross-sectional features.
Chapter 5 Rethinking Statistics with Bayesian MethodsPriors, likelihoods and posteriors for risk and reward, credible intervals, Bayesian regression with predictive checks, robust regression with fat tails, dynamic updating.
Chapter 6 Time Series Models for Trading and RiskStationarity, ACF/PACF and ARIMA as the foundations — then where time-series models still earn their keep in quant trading: volatility (ARCH/GARCH/GJR, VaR, vol targeting), structural arbitrage (cointegration and pairs, Kalman hedge ratios, regime switching), and the walk-forward discipline that underpins every ML pipeline. Mean forecasting itself has largely been ceded to ML.
Chapter 7 Modern Statistical Learning in PracticeSix methods that have moved from research papers into everyday practice, each built on what earlier chapters taught: learning to rank, quantile and conformal prediction, double machine learning, covariance shrinkage and cluster-based allocation, event-based labels and meta-labeling, and the statistics that decide whether a discovered pattern is real. The demonstrations use market data; the methods are used far beyond it — search and recommendation, demand forecasting, policy and marketing evaluation, any high-dimensional covariance, two-stage decision systems, and large-scale experimentation.
How to read this book
Every Python code block in this book runs live in your browser. Click into any cell, edit it, press the ▶ Run button, and see the output. The Python engine (Pyodide) downloads once on the first chapter — after that, everything is instant. Cells marked predict the output hide their result until you have committed to a guess; flashcards at the end of each section are scheduled by a spaced-repetition engine, so the ones you get wrong come back sooner.
This book follows ISOM 5650 lecture by lecture: Chapters 0–2 are the Python and pandas toolkit; Chapters 3–5 are the statistical models the course is graded on — predictive models, Bayesian methods, and time series; Chapter 6 is the capstone on modern statistical learning in practice.
Chapters 0–2 teach you to hold data properly — Python, Series, DataFrames — and to reshape your statistical thinking from averages to distributions, tests, associations and tails. Chapters 3–5 are the modelling core: predictive models with honest selection and a causal detour, Bayesian updating for risk and reward, and time-series models re-positioned for what they still do best in trading — volatility, structural arbitrage, and the walk-forward discipline behind every ML pipeline. Chapter 6 collects six statistical-learning methods that have become everyday practice across industries — demonstrated here on market data — and shows, method by method, how each rests on what came before.
This is not a course on neural networks, reinforcement learning, or production MLOps. Those are downstream of the foundations covered here. Get the foundations right; the rest is implementation.