Skip to main content

xpd

Run uvx xpd check . to find the lines of your Python code that are slow or give a wrong result, and add --fix to let xpd rewrite the ones it can. xpd checks code that uses pandas, Polars, NumPy, SciPy, scikit-learn, scikit-lego, MAPIE, Category Encoders, linearmodels, arch, skfolio, pymoo, plotly or Apache Hamilton. It reads the files and starts no Python, so you or a coding agent can run it after every edit.

The documentation is at https://bjoernaagaard.github.io/xpd/, with a page for every rule.

Install

xpd requires Python 3.13 or newer. Install it with uv.

uv tool install --python '>=3.13' xpd

You can also run xpd once without installing it, with uvx xpd in place of xpd.

Check a file and fix it

Save the following code as bad.py in an empty folder. xpd reads the code and doesn't run it, so you don't need pandas.

import pandas as pd

df = pd.DataFrame({"a": [1, 2], "k": [1, 2]})
other = df.copy()
for i, row in df.iterrows():
    df["a"][i] = row["a"] * 2
df.dropna(inplace=True)
m = pd.merge(df, other, on="k")
out = pd.DataFrame()
for f in ["x.csv"]:
    out = pd.concat([out, pd.read_csv(f)])

Run xpd on the file. On a terminal --format text is the default, and elsewhere xpd prints JSON. It prints one line for each issue, with the place, the severity, the rule and what to write instead, and it exits with 1 because one issue is an error.

$ xpd check bad.py --format text
bad.py:5:15: warning [pandas/row-loop] iterrows() builds a Series for every row. Compute on whole columns instead, such as df["a"] * df["w"]. When each row has to become a Python object, loop over itertuples() or to_dict("records").
bad.py:6:5: error [pandas/chained-assignment] Chained assignment writes to a copy under copy-on-write, so the frame keeps its old values. Assign to df.loc[i, "a"] instead.
bad.py:7:1: info [pandas/no-inplace] inplace=True gives no speedup and blocks chaining. Reassign instead.
bad.py:8:5: warning [pandas/merge-without-validate] merge without validate= can silently duplicate rows.
bad.py:11:5: warning [pandas/concat-in-loop] out grows by one concat per pass, and each concat copies every earlier row. Collect the frames in a list and concat once after the loop.
xpd: 5 issues, 2 more with --fix --unsafe-fixes

Fix every error, and fix a warning unless you can say why the code is right in that place.

Severity Meaning
error The code gives a wrong result or raises an exception
warning The code is slow or easy to get wrong
info A shorter or newer form exists

xpd check bad.py --fix writes the safe fixes, which keep what the code does. None of the five issues has one, so the file stays as it was. --unsafe-fixes adds the fixes that may change what the code does, so read the diff after you use it.

$ xpd check bad.py --fix --unsafe-fixes --format text
bad.py:5:15: warning [pandas/row-loop] iterrows() builds a Series for every row. Compute on whole columns instead, such as df["a"] * df["w"]. When each row has to become a Python object, loop over itertuples() or to_dict("records").
bad.py:8:5: warning [pandas/merge-without-validate] merge without validate= can silently duplicate rows.
bad.py:11:5: warning [pandas/concat-in-loop] out grows by one concat per pass, and each concat copies every earlier row. Collect the frames in a list and concat once after the loop.
xpd: fixed 2, 3 issues

xpd rewrote lines 6 and 7 and exited with 0, because no error is left.

 for i, row in df.iterrows():
-    df["a"][i] = row["a"] * 2
-df.dropna(inplace=True)
+    df.loc[i, "a"] = row["a"] * 2
+df = df.dropna()

Under pandas copy-on-write, the old line 6 left df unchanged, and the new line writes the doubled values into df. xpd check exits with 0 when it finds no error, with 1 when it finds one, and with 2 when it can't run. The Get started page explains each part of an issue.

Animate a concept

Ask an agent with the xpd plugin to animate a concept from the project, or render a Manim scene directly. The first setup pulls the pinned Cairo renderer into rootless Podman on x86-64 Linux. Later sessions can use the same renderer and load the guide offline.

xpd animate setup
xpd animate guide sequence > cache_miss.py
xpd animate render cache_miss.py CacheMiss --profile preview
xpd animate render cache_miss.py CacheMiss --profile final

The render result includes a contact sheet, editable source, and saved settings for a revision. An agent connected over local MCP can use animate_guide, animate_render, animate_artifact, and animate_source. The animation guide walks through setup, CLI and MCP rendering, and how to revise a saved scene.

Rules

Each library has a pack of rules, and a pack runs only on a file that imports its library. The Python pack runs on every file. Each rule has a page that says what goes wrong, what to write instead and whether xpd can fix it, such as pandas/chained-assignment.

Pack One of its rules What the rule reports
pandas chained-assignment df["a"][i] = v writes to a copy, so the frame keeps its old values
NumPy append-flattens np.append without axis flattens both arrays
SciPy removed-keyword tol= on the sparse iterative solvers was removed and raises TypeError
scikit-learn fit-on-test A fit on the test rows scored 0.997 AUC on data with no signal
MAPIE calibrate-on-training-rows conformalize on the training rows covered 0.468 of the test rows where 0.9 was asked
plotly marker-size-diameter A marker's size is its diameter, so markers of size 10 and 20 had areas of 78.5 and 314.2 square pixels
Python dict-str-any dict[str, Any] in a signature hides the keys the function uses

xpd rules lists every rule, and the rules overview lists the packs with their counts.

Some info rules state a preference of the house style, such as one method chain where the code builds a frame in separate steps. Set style to make xpd report them as warnings, in [tool.xpd] of the project's pyproject.toml or at the top of ~/.config/xpd/config.toml. xpd check describes the setting.

[tool.xpd]
style = "strict"

Commands

xpd <command> -h lists the options of a command, and the command reference has a page for each one.

xpd
├── lint
│   ├── check [paths]          lint files and folders, and rewrite with --fix
│   ├── rules                  list every rule with its documentation
│   └── hook                   answer an agent's session: lint each edit, and hold a turn that leaves errors or warnings
├── look up a library
│   ├── find "<task>"          find library symbols, rules and worked examples for a task
│   ├── api <name>             read one symbol, method or worked example in full
│   └── index <source>         build a search index from library source
├── read and rewrite code
│   ├── run [paths]            find a code pattern, and preview or apply a rewrite
│   ├── outline [paths]        show imports, definitions and members with line numbers
│   ├── graph <files>          print the dataflow of step code or Hamilton modules
│   └── map <file>             plan a pandas pipeline reimplementation in native Polars
├── run the project's Python
│   ├── profile <data file>    print dtypes, nulls, unique counts and memory per column
│   ├── equiv old.py new.py    run two scripts and compare the `result` each one leaves
│   └── refit <contract>       refit a saved Pipeline on raw training rows and compare
├── animate                    render and revise an editable Manim scene
├── write your own rules
│   ├── new                    create a rule project, a rule, a test case or a utility
│   └── test                   check rule examples and compare snapshots
└── connect a tool
    ├── mcp                    start the MCP server for agents
    ├── lsp                    start the language server for editors
    ├── skill                  print the agent skill for the installed version
    ├── doctor                 suggest Ruff, ty and pytest settings for the project
    └── completions <shell>    print shell completion

profile, equiv and refit run the project's Python, so they need pandas in the project's environment. index runs Python with Griffe, and the first find downloads a 333 MB search model once. check --fix, run --update-all, new, and test -U write project files when invoked in those modes, and hook records session state in xpd's cache folder.

Plan a pandas migration

xpd map features.py --entry add_features --from pandas --to polars reads the source and proposes native Polars operations. It shows the stages, observed columns and behavior that needs more evidence. Use --format json for a structured report. Exit 0 means the plan has no unresolved items, 1 means the report is partial, and 2 means xpd could not read or analyze the request.

Pass --contract migration.json to declare ordered input and output schemas, positional row identity and the caller's materialization boundary. Use the same contract with xpd equiv old.py new.py --contract migration.json to compare results from the two scripts. Both scripts must read the same inputs and assign their tables to result. The Polars script returns a materialized DataFrame in the proof even if the production consumer takes a LazyFrame. The equiv reference shows the contract fields and exit codes. The skfolio migration example includes two manifests and a replay that verifies native Polars output without pandas or skfolio installed in the native runtime.

Use xpd with an agent or an editor

You want Do Guide
An agent to see the issues of each file it edits, and to keep working while one has an error or a warning Install the plugin, or add xpd hook to the agent's hooks Claude Code and other agents
An agent to call xpd's tools claude mcp add xpd -- uvx xpd mcp Connect an agent with MCP
The hook, the MCP server and the skills in one step Install this repository as a plugin in Claude Code or Codex Agent plugin
An agent to know when to run each command npx skills add bjoernaagaard/xpd Agent skill
An agent to train a scikit-learn model with checks xpd mcp --code-mode Train a model in code mode
Issues, fixes and rule help in your editor Start xpd lsp from the editor Use xpd in an editor
A rule for your own project xpd new rule Write a rule

Install the plugin in Claude Code with the following commands. The guide has the commands for Codex.

claude plugin marketplace add bjoernaagaard/xpd
claude plugin install xpd@xpd

The plugin runs xpd hook at four points of a session.

session starts        xpd prints which rule packs apply, the style setting,
                      and the pipelines and Hamilton nodes of the project
user sends a prompt   xpd prints the playbook that answers the prompt, such as
                      xpd/recipe/plotly-chart for "improve my charts",
                      or the open issues when the prompt asks what to improve
agent edits a file    xpd reports the issues of that file
agent wants to stop   xpd lints every Python file the session changed,
                      and holds the turn while one has an error or a warning

With style = "strict", a rule of the house style counts as a warning, so the agent also keeps working until the code is in the style.

A playbook is one of xpd's own recipes. It holds the house style for a kind of task as a complete module, with the commands to run in order and the rules that the code satisfies. xpd find "<task>" returns a playbook when the task fits it, and xpd api <name> prints it.

Playbook What its code is
xpd/recipe/pandas-pipeline Step functions that each return frame.assign(...), joined with pipe
xpd/recipe/feature-module One typed function for each feature, named for the column it returns
xpd/recipe/linear-script A script that changed a frame line by line, as one chain that xpd equiv proves equal
xpd/recipe/plotly-chart A line chart that reports no issue of the plotly pack

License

You may use xpd's own code under the MIT license or the Apache-2.0 license, and the other parts that ship with xpd keep the licenses in the table.

Part License Where the text is
xpd's own code and its playbooks MIT or Apache-2.0, as you choose LICENSE-MIT and LICENSE-APACHE
Recipes, which are examples taken from library documentation The license of the library, which is MIT, BSD-3-Clause, Apache-2.0 or NCSA licenses/, one file per library. xpd api <recipe> prints the license name and the source link with the code
The Manim Community API index MIT Manim Community and 3Blue1Brown
option-ext, a dependency shipped unmodified MPL-2.0 licenses/option-ext-LICENSE.txt, with the complete source in licenses/option-ext-0.2.0-source.tar.gz and at https://crates.io/api/v1/crates/option-ext/0.2.0/download
libcst, the parser that checks a fixed file MIT, with parts of CPython under PSF-2.0 licenses/libcst-LICENSE
EmbeddingGemma, the model that find downloads The Gemma Terms of Use at https://ai.google.dev/gemma/terms Not shipped with xpd

The licenses/ folder ships in the crate, the sdist and the wheel, and the package metadata lists the combined licenses.

Metadata

Release files for xpd 0.43.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 xpd 0.43.0
File Size Uploaded Provenance Actions
xpd-0.43.0.tar.gz 8.0 MB Without provenance Details for xpd-0.43.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for xpd 0.43.0
File Actions
xpd-0.43.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for xpd-0.43.0-py3-none-win_amd64.whl
xpd-0.43.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for xpd-0.43.0-py3-none-musllinux_1_2_x86_64.whl
xpd-0.43.0-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details for xpd-0.43.0-py3-none-musllinux_1_2_aarch64.whl
xpd-0.43.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for xpd-0.43.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
xpd-0.43.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for xpd-0.43.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
xpd-0.43.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for xpd-0.43.0-py3-none-macosx_11_0_arm64.whl
xpd-0.43.0-py3-none-macosx_10_15_x86_64.whl Python 3 none macOS 10.15+ x86-64 Details for xpd-0.43.0-py3-none-macosx_10_15_x86_64.whl

Total release size: 144.5 MB

Release files / xpd-0.43.0.tar.gz

Download URL xpd-0.43.0.tar.gz
Size 8.0 MB
Tags Source
SHA-256 checksum
How to use checksums
60bb7f01eebc6fba815fccf93e0e930580799e6e4fbf75642405e8c852e94e4b
BLAKE2b-256 checksum
How to use checksums
2a43af3f54e6caa544cdbd9323a811c4c97e8948da8f742457f0bae2a47e447e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.43.0-py3-none-win_amd64.whl

Download URL xpd-0.43.0-py3-none-win_amd64.whl
Size 19.6 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
7436cc28459ae6194bfaa81517f0a94d6a455f417655aa36fafbb2f533bf2269
BLAKE2b-256 checksum
How to use checksums
e1952306ab5aae50ba4fbdf4747a37d6ac35dc8446cb9c051a5ab53b18b822fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.43.0-py3-none-musllinux_1_2_x86_64.whl

Download URL xpd-0.43.0-py3-none-musllinux_1_2_x86_64.whl
Size 19.6 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
c897e887c33b65e34bf2b27050bd747ebca1d02f6b4a66b849cc1fcd2bb122f6
BLAKE2b-256 checksum
How to use checksums
59d64042fc5f8c469815ffcfaa0ad95c1757347640e54f82ab362116646f07c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.43.0-py3-none-musllinux_1_2_aarch64.whl

Download URL xpd-0.43.0-py3-none-musllinux_1_2_aarch64.whl
Size 19.1 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
dfcd14597879437f740a79ef38f59c4adaf9722dba500849e26780acecd96342
BLAKE2b-256 checksum
How to use checksums
b2940328179b3d88f9aea1c3e10832097f8fa57d6db11362249652d50ea47b4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.43.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL xpd-0.43.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 19.7 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
10fd112a6c013738c78a1c876f504027263ed09428cc71e298d24a728dbe22d5
BLAKE2b-256 checksum
How to use checksums
85a8d86df50c8c4f52eceab52400fea626bf0af8ba7b93f743cedee317ecd755
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.43.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL xpd-0.43.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 19.3 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
9938a9723c8fbc63e4cc63bdc21a0eeeb0f84b0f58f844ab6b46ff38096d23ec
BLAKE2b-256 checksum
How to use checksums
80ac0caea6a31b7e3ff604e0d5e5c37454c93bca099493510572e38d9fcbf267
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.43.0-py3-none-macosx_11_0_arm64.whl

Download URL xpd-0.43.0-py3-none-macosx_11_0_arm64.whl
Size 19.6 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
43d9863b5058090f8a59c84185026f4cd0431f3f277126ee159f3593ad31b8c2
BLAKE2b-256 checksum
How to use checksums
4ee349e2aa299edc30da2938acefe7b5594fbf7eb90c9e35db06785a7caa60ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.43.0-py3-none-macosx_10_15_x86_64.whl

Download URL xpd-0.43.0-py3-none-macosx_10_15_x86_64.whl
Size 19.5 MB
Tags Python 3 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
122347e09fc77686f9ffb49581cbd4780931ba26fe60dabf4b6883690ffe5a1b
BLAKE2b-256 checksum
How to use checksums
1d131c4d4f589e9fc835616ea61ead9a77e0b17674f89f78a8ff8b7ae247a8cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for xpd 0.43.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.43.0 This release

8 release files No provenance

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