Skip to main content

chadwickpy logo

chadwickpy

Retrosheet play-by-play files to data tables. Pure Python, one pip install.

CI PyPI Python versions Downloads License Docs

Retrosheet publishes every play of every MLB game as text files. The Chadwick tools turn those files into tables. chadwickpy is those same six tools, rewritten in pure Python: no compiler, no C library, no dependencies. Output is byte-identical to Chadwick on every Retrosheet season that has game data, 1897 to 2025 (for inputs where the C behaves in a defined way).

pip install chadwickpy            # or: uvx --from chadwickpy cwevent -h
curl -O https://www.retrosheet.org/events/2010seve.zip
unzip -q 2010seve.zip -d retro2010 && cd retro2010
cwevent -y 2010 -n -f 0,2,3,4,10,14,29,34 2010NYA.EVA > yankees_events.csv
"GAME_ID","INN_CT","BAT_HOME_ID","OUTS_CT","BAT_ID","PIT_ID","EVENT_TX","EVENT_CD"
"NYA201004130",1,0,0,"aybae001","petta001","S9/F9S-",20
"NYA201004130",1,0,0,"abreb001","petta001","K",3
"NYA201004130",1,0,1,"huntt001","petta001","8/F8LXD",2

The six tools

Tool One row per
cwevent event (a play): up to 164 columns
cwgame game
cwdaily player per game (batting, pitching, fielding)
cwsub substitution
cwcomment scorer comment
cwbox game, as a text or XML box score (SportsML is deprecated: Chadwick's own -S crashes)

Same command names and options as Chadwick. Also usable from Python (from chadwickpy.tools.events import event_rows).

Good to know

  • Speed: on one core chadwickpy is roughly 10 to 40 times slower than the C tools. With several files (a whole season) it uses several cores by itself: a full 2,430-game season takes about 2 seconds on a multi-core machine, the same as the C tools on one core. The output is identical at every core count (checked from 1 to 40). See the cores guide.
  • Choose the number of workers with -j <workers> (-j 1 is sequential) or the CHADWICK_JOBS environment variable. By default it follows the CPUs the process may use, including a CPU limit set by Docker, Kubernetes or systemd.
  • It reads Retrosheet's files; it does not include or download them.
  • Pure Python, zero dependencies. Python 3.11 or newer; CI runs Python 3.11 to 3.13 on Linux, and it was also checked on 3.14. It should work on macOS and Windows too (on Windows it expands wildcards such as 2010*.EV* itself, as the C tools do), but those are not part of the automated tests.

Documentation

https://cbwinslow.github.io/chadwickpy/: getting started, a guide to each tool, Python usage, recipes, the full option and field reference, how it was verified, and an FAQ. Machine-readable: llms.txt.

Verification

Output is compared byte for byte (standard output, error messages and exit status) with the real Chadwick programs, built from the 0.11.0 release (tag v0.11.0):

  • every season with game data, 1897 to 2025, all six tools and 16 option sets (2,064 comparisons);
  • every output field of every tool on its own and in combination, both output formats, and every game-selection option;
  • tests aimed at every remaining branch of the code (99% of the lines and branches were reached when measured on 0.3.0; the 0.4.0 suite of 5,163 tests passes against the real tools), and the rest are listed with the reason they cannot be;
  • a weekly check against the newest Chadwick, and a test that fails when any C function changes.

Details and how to run them yourself: How it was verified. CI builds Chadwick and runs the whole suite on Python 3.11-3.13, failing on any skipped parity test.

Licence and credit

GPL-3.0-or-later (LICENSE). chadwickpy is a derivative work of Chadwick, Copyright (C) 2002-2026 Dr T L Turocy and the Chadwick Baseball Bureau, GPL-2.0-or-later (COPYING-chadwick, NOTICE); each ported module keeps that notice. It is independent: Chadwick and Retrosheet do not endorse or sponsor it, and it ships no Retrosheet data.

Retrosheet's data-use notice asks that anyone using its data say so. If you publish anything built on it, include:

The information used here was obtained free of charge from and is copyrighted by Retrosheet. Interested parties may contact Retrosheet at "www.retrosheet.org".

Contributing, questions, security

CONTRIBUTING.md · Discussions · Issues · SECURITY.md. The rule of the project: the port stays a translation of Chadwick's C; rules come from the C, never from tuning output.

Metadata

Release files for chadwickpy 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chadwickpy 0.4.0
File Size Uploaded
chadwickpy-0.4.0.tar.gz 439.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chadwickpy 0.4.0
File Interpreter ABI Platform
chadwickpy-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 566.4 kB

Release files / chadwickpy-0.4.0.tar.gz

Download URL chadwickpy-0.4.0.tar.gz
Size 439.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a1800b966d81407e4cbceaffac6bf9c3eba4dc37c2f36a590f70bb0a2fc7f800
BLAKE2b-256 checksum
How to use checksums
835485d730da1241a75117311d06d36ba8d5a6114711ce67f66558f4bae658a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / chadwickpy-0.4.0-py3-none-any.whl

Download URL chadwickpy-0.4.0-py3-none-any.whl
Size 126.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66c88a848c1a29cf222d41eaeac269d166ef92a36220ad29f2f7afccc35abf40
BLAKE2b-256 checksum
How to use checksums
95877905d8d440d8d026e4481acb9ecf0cd1a662f1e99078f84fa9c19ea2f36a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page