Appendix C: Python Packages

This appendix lists every Python scientific library used across the book: what it is for, the chapters that apply it, and the package version used when compiling this edition. Appendix A shows how to install all of them into a project virtual environment using pip.

In Python, a library (or package) is a reusable collection of modules, functions, classes, and documentation shared via the Python Package Index (PyPI). Python includes a robust standard library (sys, os, math, json, datetime) available without installation; third-party scientific packages are installed once via pip install <package> and imported into your analysis sessions using import <package>.

The packages in this book

Table 1.1 summarizes the packages used in this book.

Table 1.1: The Python scientific packages used in this book.
Area Package What it is for Chapters Version
0 Data `data2thesis` Graduate Wellbeing Study case-study datasets a... 1, 2, 3, and later 1.1.0
1 Core & Computing `numpy` Multidimensional arrays, numerical routines, a... 1, 2, 3, and later 2.5.4
2 Data Handling `pandas` Foundational tabular data structures (DataFram... 1, 2, 3, and later 3.1.0
3 Data Formats `openpyxl` Reading and writing Microsoft Excel (.xlsx) fi... 2 3.1.5
4 Data Formats `pyreadstat` Reading SPSS (.sav), Stata, and SAS datasets w... 2, 19 1.3.7
5 Visualisation `matplotlib` Foundational scientific plotting engine, layou... 1, 4, 5, and later 3.11.2
6 Visualisation `seaborn` Statistical visualization: histograms, scatter... 1, 2, 4, and later 0.13.2
7 Statistics `scipy` Probability distributions, hypothesis testing ... 1, 2, 5, and later 1.18.1
8 Statistical Modeling `statsmodels` Classical statistical models: OLS regression, ... 1, 5, 6, and later 0.15.0
9 Machine Learning `scikit-learn` Machine learning: preprocessing, pipelines, cl... 1, 9, 11, and later 1.9.1
10 Machine Learning `xgboost` Scalable and accurate gradient boosted decisio... 12, 13 -
11 Deep Learning `torch` PyTorch deep learning framework for multilayer... 15 -
12 Time Series `statsmodels.tsa` Time series analysis, seasonal decomposition (... 1, 5, 6, and later 0.15.0
13 Reporting & Apps `shiny` Shiny for Python: reactive web applications, i... 17 -
14 AI & Automation `requests` HTTP requests for connecting to local and remo... 17, 18 2.34.2

The core scientific stack

Rather than requiring dozens of disparate packages, scientific Python is built on a coherent, tightly integrated stack:

  1. pandas and numpy: The foundation for tabular data structures and numerical operations. A DataFrame is the Python counterpart of a spreadsheet or database table, with support for filtering, grouping, joining, and missing-value imputation.
  2. matplotlib and seaborn: The standard libraries for visualization. Matplotlib provides low-level graphical rendering and layout control, while Seaborn offers high-level statistical plotting routines (histograms, regression plots, and boxplots).
  3. scipy and statsmodels: The statistical modeling core. Scipy provides probability distributions and classical hypothesis testing (\(t\)-tests, chi-square, Mann-Whitney), while Statsmodels handles econometric and regression models with comprehensive diagnostic tables (OLS, logistic regression, ANOVA, and linear mixed-effects).
  4. scikit-learn: The premier machine learning toolkit for empirical research, providing consistent APIs (fit, transform, predict) for supervised classification, regression, clustering, and cross-validation pipelines.