Skip to content

xpd data-prep

Use xpd data-prep to check Python preparation code from raw data through imputation, splitting, and scaling the features and target. The data preparation guide shows how to record the work.

The bare command lists findings, the pipeline graph, a checklist question about excluded source columns, and optional column facts and questions. Findings are grouped by leakage, joins, target transforms, coercion, and pipeline shape. Use --format json to get their stable IDs, and --questions to list the catalog without scanning files.

Terminal window
xpd data-prep [OPTIONS] [PATHS]...
xpd data-prep <COMMAND>
Subcommand What it does
xpd data-prep start Start a run: record the commit it starts from, the paths, line count, checks and optional benchmark of the project
xpd data-prep plan Record the plan of a round: the fixes in order, and the findings that are right as they are
xpd data-prep approve Record that the user said yes to a fix that changes what callers or users see
xpd data-prep gate Gate a fix that is committed: run the checks, time --bench when set, count lines and compare the findings with the commit before it. Exit 1 when the fix is not kept
xpd data-prep drop Record that a fix was given up, after its files were restored
xpd data-prep status Print the run and the stage that comes next
xpd data-prep finish End the run: compare findings, line count and benchmark timing with the start commit. Exit 1 while a fix is open or a new finding has no reason
Argument What it does
<PATHS>... Files or directories (directories respect .gitignore)
Option Default What it does
--kind <KIND> List only the findings of these kinds, separated by commas. Repeatable. Values: fit-before-split, fit-on-test, cross-val-on-fitted-data, vectorizer-fit-then-transform, scaler-fit-before-split, prefit-before-cross-validation, merge-without-validate, polars-join-without-validate, merge-without-on, merge-asof-unsorted, polars-join-asof-unsorted, concat-columns-unchecked, join-key-unvalidated, joiner-conflicting-keys, transformed-target-pair, scaled-target-without-inverse, compare-to-missing, polars-null-comparison, compare-to-nan, nan-to-int, apply-cast, astype-then-to-numpy, silent-dtype-coercion, arbitrary-outlier-capper-empty, quantiles-capping-invalid-fold, stateful-function-transformer, unfitted-keep-subsampling, read-parquet-all-columns, no-inplace, frame-column-write, lambda-in-assign, nested-step-calls, script-steps.
--limit <LIMIT> 20 The most findings to list of each kind, strongest first. 0 lists every finding.
--since <COMMIT> Count the findings at this commit too, and print each count beside the count of today.
--group-by <GROUP_BY> none Group findings and checklist items by owning module or shared cause. Values: none (Keep the default flat per-kind listing), module (Group findings and checklist items by owning module path), cause (Group related findings by shared kind and anchor files).
--packet <N> Emit one 1-indexed deterministic context-budgeted review packet for the Nth cluster.
--budget-lines <LINES> 300 Maximum source lines included across excerpts inside a --packet view.
--all-modules Include checklist review items for every surveyed module, not only modules with findings.
--format <FORMAT> Output format. Default: text on a terminal, json otherwise. Values: text, json.
--adapter <ADAPTER> A Python adapter file or shell command that emits column facts.
--target <COLUMN> Name the target column.
--questions Print the facts and questions catalog without a file scan.

Pass --adapter prep.py when a Python file defines columns() returning a pandas or Polars frame, a skrub.TableReport, a path, or a dictionary of lists. xpd runs it in the project's Python with pandas and SciPy. A shell command adapter prints JSON with a columns array of measured column objects. It may supply rows, target and model_family. Each column object has a column name and may supply min, skew, outlier_share and zero_share for scaling advice.

--target <column> overrides the adapter's target name. Otherwise xpd uses the adapter's target or infers it from a column named y, target or label. A survey with no named target still gets feature questions.

Stage Command
Start xpd data-prep start <paths> --check "<command>" --adapter prep.py
List xpd data-prep <paths> --adapter prep.py --format json
Plan xpd data-prep plan plan.json
Approve an interface change xpd data-prep approve <fix-id>
Gate a committed fix xpd data-prep gate <fix-id>
Drop a restored fix xpd data-prep drop <fix-id> --reason "<reason>"
Resume xpd data-prep status
Finish xpd data-prep finish

xpd stores runs under .git/xpd-data-prep.json, or in the shared .git/xpd-ledger.sqlite in durable mode. Finish exits 1 when a fix is open, a new finding needs a reason, or a checklist item is unanswered.

Terminal window
$ xpd data-prep --questions --format json | jq -c '{facts: (.facts | length), questions: (.questions | length)}'
{"facts":14,"questions":14}
Code Meaning
0 The requested list or run stage succeeded.
1 The gate rejected the fix or the run has unresolved work.
2 The command could not run, for example because the arguments or recorded adapter were invalid.