# Coding for Economists: a book that only publishes if its code runs

> The repository behind the open textbook Coding for Economists holds the Jupyter notebooks, Quarto pages and Python environment for every chapter, so a broken data call blocks the whole publication. It is written for economists learning to code and for contributors who want to run the book locally.

**aeturrell/coding-for-economists** — This repository hosts the code behind the online book, Coding for Economists.

- Repository: https://github.com/aeturrell/coding-for-economists
- Website: https://aeturrell.github.io/coding-for-economists
- Stars: 946 · Forks: 159
- Language: Jupyter Notebook
- License: MIT
- Published: 2026-10-20 · Updated: 2026-10-20 · Language: en
- Canonical page: https://hysenlabs.com/projects/aeturrell-coding-for-economists

## The repository holds the book, not just the code samples

Coding for Economists is an online book about programming for economists, and aeturrell/coding-for-economists is the source of that book rather than a library anyone installs. The top level of the repository is a flat list of chapter files: notebooks such as code-basics.ipynb, code-advcd-best-practice.ipynb and data-joining-data.ipynb sit next to Quarto pages such as coming-from-excel.qmd, coming-from-stata.qmd, craft-intro.qmd and econmt-causal-inference.qmd. There are also chapters specifically for people arriving from another tool, R, MATLAB, Stata and Excel, plus a quickstart notebook for people who want the shortest path.

That structure tells you something important about how the book teaches. Each chapter is a working file, not a snippet pasted into a page. The primary language recorded for the repository is Jupyter Notebook, and the topics list includes econometrics, economics-models, data-science and learning. The chapters that matter are numbered by topic: data extraction, missing values, spreadsheets, categorical data, then the economics-specific material on regression, generalised models, Bayesian work with PyMC and Bambi, causal inference and diagnostics.

The audience is stated plainly in the project description: a guide for economists on what programming is, why it is useful, and how to do it. The reading experience is separate from this repository. The published text lives at the project homepage, and the README directs readers to the website rather than to a local build.

## quarto render --execute is the gate every chapter passes through

The core mechanism of this repository is a render step that executes the code, which means the publication pipeline fails whenever a data call or a model breaks. The contributor instructions give the command as the way to check changes.

```bash
uv run quarto render --execute
```

The flag matters. Without it, Quarto would only format the prose and embed existing outputs. With it, every code cell runs inside the book environment before the page is written. A chapter that calls a remote data source, fits a model, or plots with a font that is missing will fail at render time rather than publish a stale picture.

Reading the result locally is a separate command, served over a plain HTTP server from the _book directory.

```bash
uv run python -m http.server -d _book 8000
```

You then open http://localhost:8000 in the browser. The book configuration lives in _quarto.yml, and the rendered output lands in _book, which is why the Docker workflow later copies app/_book/ back to a local machine. There is a csl/ directory for citation styles, favicon.ico at the root, and helper scripts such as craft_diss_pyramid.py and data_set_prep.py that generate parts of the text rather than being read by it. Understanding that split is the difference between editing a chapter and editing the machinery around the chapters.

## One pinned interpreter and a dependency list of sixty libraries

The environment is declared in pyproject.toml, and the pin is narrow. The project metadata sets requires-python = ">=3.10,<3.11", which means a Python 3.11 or 3.12 interpreter will not satisfy the project as declared. The project name is CodingforEconomists and the version recorded there is 1.0.7.

The dependency list is long enough that the word "data science" covers only part of it. Direct entries include pandas, polars, numpy, scipy, statsmodels, scikit-learn, pymc, bambi, pyfixest, stargazer, pingouin, ruptures and specification-curve for the statistical side; matplotlib, plotly, plotnine, seaborn, lets-plot, altair, joypy, pywaffle, wordcloud, waterfallcharts, geopandas and geoplot for graphics; ibis-framework with the sqlite extra, sqlmodel, pandera and feature-engine for data engineering and validation. osmnx, palmerpenguins, pandas-datareader, pandasdmx, workalendar and yfinance are listed, so several chapters read live or bundled external data.

The list also carries toolchain packages: ruff, pre-commit, pytest, toml, loguru, rich, python-slugify and python-dotenv, and nbstripout for clearing notebook outputs. Writing tools are present too, through spacy, nltk, textstat and sympy. If you add a package for a chapter, the contributor instructions are explicit that it happens through uv add, and that the environment change belongs in the same commit as the content change.

## The Docker route asks for 15Gb of RAM before it does anything useful

The contributor documentation calls the Dockerfile the easiest way to set up a development environment, and it is the most complete reproduction of the toolchain. The image starts from python:3.10.16-slim, installs system packages including graphviz, texlive, build-essential, wget, curl and unzip, then installs the Varta fonts the book uses. uv is copied in from a separate image stage, the project files are copied first, and dependencies are installed with a frozen lockfile before the source is copied in.

```dockerfile
FROM python:3.10.16-slim
```

```bash
RUN uv sync --frozen
```

The cost is stated plainly in a comment at the top of the file: building this image needs 15Gb or more of RAM dedicated to Docker. That figure is a real constraint for anyone on a laptop with a modest memory ceiling, and it is the practical difference between the Docker path and the local one.

The workflow around the container is also opinionated. The instructions assume Docker, the Docker extension for VS Code and the VS Code Remote extension, then describe building the image from the Dockerfile in VS Code, running it interactively, and attaching a remote window to the running container before opening the app folder. The built HTML can then be pulled back to the host machine.

## Fonts and NLP models are the setup steps people skip

Three prerequisites sit outside the Python package manager, and each one produces a confusing failure if it is missed. The first is the language models. The contributor notes require the spaCy English model and the nltk model set to be downloaded inside the project environment.

```bash
uv run python -m spacy download en_core_web_sm
```

```bash
uv run python3 -m nltk.downloader all
```

The second is fonts. The book sets text in Varta, which the documentation points to on Google Fonts, and the Dockerfile fetches the archive directly from wfonts.com and installs the .ttf files into the system font directory. The third is LaTeX, since the book was built with TeX Live.

The font problem has a documented sting in the tail. If you install the fonts by hand, Matplotlib may keep serving the old set from its cache, and the fix is to remove the cache file.

```bash
rm ~/.matplotlib/fontlist-v330.json
```

This is a small but telling detail about the project. A chapter that renders perfectly on the maintainer's machine can produce different-looking output on yours, and the cause is a font cache rather than anything in the analysis code.

## Releases are cut from a version bump in pyproject.toml

Publishing is automated and the release steps are unusually prescriptive, which reduces the chance that a tag and a published book drift apart. The documented sequence starts with a branch named for the new version, then a change to the version field in pyproject.toml, then a commit whose message is the new version label, with tests passing. A pull request is opened and merged into main.

From there the workflow is hands off. A GitHub Action drafts a release from that merge commit and uses the new version as the tag, publishes the release, uploads the new version of the book, and updates the Zenodo repository and the version badge on the intro page. The intent is stated as consistency between the release and the site hosted on GitHub Pages.

Two things follow from that design. First, the version in pyproject.toml is load bearing. Change the number and you change the tag, the badge and the archive record together. Second, the archived releases show the cadence of that process. Recent releases include v1.0.7 on 2026-04-12, v1.0.6 on 2025-03-26 and v1.0.4 on 2025-01-03. The last push to the repository was on 2026-10-16, so the source is being changed well after the most recent tagged release.

Publication is also available by hand, although the contributor notes say you should rarely need it.

## What this repository is not for

The clearest limitation is stated by the contributor notes themselves. The README is aimed at people who are contributing to the book, and the section on contributing says contributions are welcome but that if you are planning to make a pull request you should lodge an issue to discuss it first. The exception is corrections, typos and fixing out of date package issues, which you can take straight to a pull request. That is a real gate for newcomers, and it means an unsolicited large chapter addition is likely to stall in discussion.

Second, this is not a teaching package you can add to your own project. The dependency list is pinned for one book's execution, the notebooks are written as book chapters, and the environment expects a rendering toolchain that most analysts will not otherwise have. If your goal is to learn pandas for your own work, the notebooks are readable in the published site without any of this setup.

Third, there is a maintenance caveat. The chapters reach for live external sources, including data readers and market data, and the dependency list already carries fixes for out of date package issues. Expect to run uv add to repair a chapter over time, and expect the pinned Python 3.10 range to become the thing that blocks you first. Licence position is simple: the licence field on the repository says MIT, so the code and content carry a permissive notice with no copyleft obligation attached to reuse.

## Conclusion

Economists who want to read the book should use the published website, not this repository. People who want to contribute should clone it, install uv, run quarto render --execute and confirm the page renders before opening a pull request, since the maintainer states that a pull request needs an issue first unless it is a correction, typo or stale package fix. Anyone whose research depends on these exact dependency versions should check the pyproject.toml pin on requires-python = ">=3.10,<3.11" before assuming the code will run on a newer interpreter.

## FAQ

### How do I run Coding for Economists locally?

Install uv, then render the book with quarto render --execute and serve the _book directory using uv run python -m http.server -d _book 8000. The contributor notes also describe a Dockerfile route that packages the environment, including fonts, LaTeX and the language models.

### What are the prerequisites for contributing to Coding for Economists?

The contributor notes list an installation of uv, the spaCy English model and the nltk models downloaded inside the Python environment, the special fonts such as Varta from Google Fonts, and LaTeX since the book was built with TeX Live. Each of these can be seen set up in the Dockerfile.

### Is the Coding for Economists repository suitable for production use?

It is a book source repository rather than a library, and the project is published under an MIT licence. The pyproject.toml pin of requires-python = ">=3.10,<3.11" and the large dependency list mean you would be importing a rendering environment, not a reusable package.

### Why do my charts not show the Varta font after installing it?

Matplotlib caches the font list, so newly installed fonts may not appear until the cache file is removed. The contributor notes give the removal of ~/.matplotlib/fontlist-v330.json as the fix.

### How is a new release of Coding for Economists published?

You branch with the new version name, change the version in pyproject.toml, commit with the version label as the message, and merge through a pull request into main. GitHub Actions then draft and publish the release, upload the new book, and update the Zenodo repository and the version badge.

## Sources

- [aeturrell/coding-for-economists on GitHub](https://github.com/aeturrell/coding-for-economists)
- [License: MIT](https://github.com/aeturrell/coding-for-economists/blob/main/LICENSE)
- [Project website](https://aeturrell.github.io/coding-for-economists)
- [README](https://github.com/aeturrell/coding-for-economists/blob/main/README.md)
- [Releases](https://github.com/aeturrell/coding-for-economists/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/aeturrell-coding-for-economists
