Data Quality Pipeline
Use When
- Use when tabular data must be cleaned, profiled, joined, scored, or prepared for
research analysis.
Do Not Use When
- Do not use when the task is pure prose and no dataset is involved.
Data Intake Guidance
- Raw dataset path or source, intended claim or decision, expected grain, and source
reliability context.
Data Method Detail
- Run the pipeline below in order and load only the reference needed for the current
stage.
Quality Standards
- Every dataset must preserve provenance, row-count changes, quality scores, and
analysis limitations.
Legacy Data Pitfalls
- Do not skip encoding, tidy checks, merge validation, or manifest creation.
Data Deliverable Detail
- Clean dataset, profile, quality score, manifest, or blocker report.
References
- Use the reference index below for stage-specific guidance.
Single entry skill for any tabular data passing through the engine. Detail in references/; SKILL.md is the orchestrator. For finding datasets in the first place, load dataset-discovery-and-analysis.
The pipeline (run in this order)
raw bytes
↓ (1) encoding repair → references/encoding-and-unicode.md
clean text bytes
↓ (2) tidy check → references/tidy-data-craft.md
tidy DataFrame
↓ (3) clean → references/cleaning-pandas.md
clean DataFrame
↓ (4) outlier panel → references/anomaly-detection.md
flagged DataFrame
↓ (5) merge audit → references/merge-discipline.md (only if joining)
merged DataFrame
↓ (6) quality score → references/quality-assessment-walker.md
DataQualityScore + manifest
↓ (7) ship gate
output Parquet + manifest
Skipping a step produces silent data quality failures downstream.
Reference index
| Stage |
Reference |
What it does |
| 1. Encoding repair |
references/encoding-and-unicode.md |
charset-normalizer + ftfy + BOM strip; runs before any pandas read |
| 2. Tidy check |
references/tidy-data-craft.md |
Wickham violation linter (columns_are_values / multiple_vars_per_column / vars_split_rows_cols) |
| 3. Cleaning |
references/cleaning-pandas.md |
Walker + Chen recipe library — types, missing values, duplicates, normalisation |
| 4. Anomaly detection |
references/anomaly-detection.md |
IQR + z-score + Isolation Forest panel; skew-aware method selection |
| 5. Merge audit |
references/merge-discipline.md |
Walker checkmerge + Chen validate= cardinality; mandatory before any join |
| 6. Quality score |
references/quality-assessment-walker.md |
Four-axis composite (completeness · usefulness · reliability · relevance), default weights (0.25, 0.25, 0.30, 0.20), passes(threshold=0.7) gate |
| Analytics method gate |
references/analytics-quality-method-gate.md |
Descriptive / diagnostic / predictive / prescriptive method-fit gate before quantitative claims, forecasts, dashboards, or models |
| Cross-cutting |
tools/data/profiler.py |
Profile DataFrame: dtypes, distributions, cardinality, skew/kurt hints |
The four-axis quality score (engine's gate)
Every dataset that ships carries a score with these axes:
| Axis |
Default weight |
What it measures |
| Completeness |
0.25 |
Missing-value rate per column; required-column presence |
| Usefulness |
0.25 |
Required columns present; cardinality fit; type validity |
| Reliability |
0.30 |
Source tier (source-evaluation) + provenance + duplicate rate |
| Relevance |
0.20 |
Match to research topic, geographic scope, time range |
Composite score: weighted sum. Default ship gate: composite ≥ 0.70. Lower thresholds require explicit override and reason.
The provenance packet (required output per dataset)
Every dataset that survives the pipeline produces:
projects/<id>/data/dataset.parquet # the cleaned data
projects/<id>/data/dataset.profile.json # profile (dtypes, distributions, cardinality)
projects/<id>/data/dataset.dq.json # four-axis quality score
projects/<id>/data/dataset.manifest.json # provenance: source, fetched_at, encoding,
# cleaning_steps_applied, tidy_violations_fixed,
# outliers_flagged, merge_audit, dq_score
Without the manifest, the data is not shippable.
The non-negotiable rules
- Encoding first. No
pd.read_csv before references/encoding-and-unicode.md has run. Default encoding='utf-8-sig'.
- Tidy before analysis. Load
references/tidy-data-craft.md; lint for the three Wickham violations; fix them.
validate= on every merge. Load references/merge-discipline.md. Default validate='one_to_one' or 'one_to_many' — never default-merge.
- Outlier panel, not single test. Load
references/anomaly-detection.md. IQR for skewed; z-score for normal; Isolation Forest for high-dimensional. Consensus across 2+ methods before flag.
- Score before ship. Load
references/quality-assessment-walker.md. Composite ≥ 0.70 default; sub-axis ≥ 0.50 each.
- Manifest always. No dataset ships without the provenance packet.
- Method fit before claims. Load
references/analytics-quality-method-gate.md
before statistical tests, forecasts, dashboards, or ML models. Downgrade the claim if
the data only supports a simpler analytics type.
Universal anti-patterns
pd.read_csv with no encoding repair → silent BOM-corruption of first column header.
- Cleaning before checking tidiness → fixing rows that should not exist as separate rows.
- Default
pd.merge → silent fan-out duplication in many-to-many joins.
- Single-method outlier detection → either too strict (z-score on skewed) or too loose (IQR on multimodal).
- Quality score reported as one number without sub-axes → hides which axis failed.
- Cleaning step that drops rows without logging the reason → unrecoverable data loss.
- Manifest written by hand → drifts from actual processing.
- Reporting
n_rows without n_duplicates_removed, n_outliers_flagged, n_merge_orphans.
Universal ship gate
Companion skills
Inputs
| Input |
Source/provider |
If absent |
| Raw dataset, schema, provenance, intended analysis |
Data owner and retrieval record |
Stop transformation; request source and purpose |
| Quality thresholds and join keys |
Analysis plan |
Profile first and mark thresholds undecided |
Capability Contract
Profiling is read-only by default. Cleaning, overwriting, deleting, merging, publishing, or certifying data requires explicit authority and preserved raw inputs.
Degraded Mode
Without executable tools or complete metadata, return a manual profile with unassessed axes and never label the dataset clean or fit for use.
Decision Rules
| Choice |
Action |
Failure/risk avoided |
| Encoding damage is reversible |
Repair on a copy and log mapping |
Silent corruption |
| Join cardinality differs from expectation |
Stop merge |
Row multiplication |
| Quality threshold fails |
Block downstream analysis |
Misleading result |
Data Correction Examples
- Editing the raw file; preserve it.
- Dropping outliers automatically; investigate them.
- Merging without cardinality checks; audit keys.
- Treating blanks as zeros; preserve semantics.
- Passing an unassessed axis; mark it.
Data Quality Scenario
A many-to-many join that was expected to be one-to-one stops before output and records the duplicate keys.
Companion skills
dataset-discovery-and-analysis — find the data before this pipeline runs.
source-evaluation — reliability axis depends on this.
web-scraping-foundations — when the data has to be scraped.
research-orchestration — when the data is feeding a research project.
report-and-proposal-craft, academic-writing — when the data feeds a written artifact.
Workflow
- Preserve raw data, provenance, schema, intended use, and checksum.
- Profile encoding, structure, missingness, duplicates, ranges, keys, and anomalies.
- Stop when provenance is absent, a join violates cardinality, or a quality gate fails.
- Recover on a copy by repairing documented defects and rerunning the affected profile.
- Release the cleaned data, manifest, quality score, and issue register together.
Outputs
| Artefact |
Consumer |
Acceptance condition |
| Clean dataset, manifest, profile, and issue register |
Analyst and downstream workflow |
Raw data is preserved and every transformation, join, exception, and unassessed axis is recorded |
Evidence Produced
| Evidence |
Consumer |
Acceptance condition |
| Before-and-after profiles, checksum, and transformation log |
Data reviewer and release owner |
Results reproduce from the preserved raw input and logged operations |
Anti-Patterns
- Editing the raw file. Fix: transform an immutable copy.
- Dropping outliers automatically. Fix: investigate and document disposition.
- Merging without cardinality checks. Fix: assert key relationships first.
- Treating blanks as zeros. Fix: preserve missing-value semantics.
- Passing an unassessed axis. Fix: mark it unassessed and block dependent claims.
Worked Example
A many-to-many join expected to be one-to-one stops before output, records duplicate keys, repairs the mapping, and reruns validation.
1---2name: data-quality-pipeline3description: Use when profiling, cleaning, merging, or validating tabular research data through encoding, tidy-structure, anomaly, lineage, and quality gates; use dataset-discovery-and-analysis first when the dataset still needs to be found or retrieved.4---56# Data Quality Pipeline78<!-- dual-compat-start -->9## Use When1011- Use when tabular data must be cleaned, profiled, joined, scored, or prepared for12 research analysis.1314## Do Not Use When1516- Do not use when the task is pure prose and no dataset is involved.1718## Data Intake Guidance1920- Raw dataset path or source, intended claim or decision, expected grain, and source21 reliability context.2223## Data Method Detail2425- Run the pipeline below in order and load only the reference needed for the current26 stage.2728## Quality Standards2930- Every dataset must preserve provenance, row-count changes, quality scores, and31 analysis limitations.3233## Legacy Data Pitfalls3435- Do not skip encoding, tidy checks, merge validation, or manifest creation.3637## Data Deliverable Detail3839- Clean dataset, profile, quality score, manifest, or blocker report.4041## References4243- Use the reference index below for stage-specific guidance.4445Single entry skill for any tabular data passing through the engine. Detail in `references/`; SKILL.md is the orchestrator. For finding datasets in the first place, load `dataset-discovery-and-analysis`.4647## The pipeline (run in this order)4849```50raw bytes51 ↓ (1) encoding repair → references/encoding-and-unicode.md52clean text bytes53 ↓ (2) tidy check → references/tidy-data-craft.md54tidy DataFrame55 ↓ (3) clean → references/cleaning-pandas.md56clean DataFrame57 ↓ (4) outlier panel → references/anomaly-detection.md58flagged DataFrame59 ↓ (5) merge audit → references/merge-discipline.md (only if joining)60merged DataFrame61 ↓ (6) quality score → references/quality-assessment-walker.md62DataQualityScore + manifest63 ↓ (7) ship gate64output Parquet + manifest65```6667Skipping a step produces silent data quality failures downstream.6869## Reference index7071| Stage | Reference | What it does |72|---|---|---|73| 1. Encoding repair | `references/encoding-and-unicode.md` | charset-normalizer + ftfy + BOM strip; runs before any pandas read |74| 2. Tidy check | `references/tidy-data-craft.md` | Wickham violation linter (columns_are_values / multiple_vars_per_column / vars_split_rows_cols) |75| 3. Cleaning | `references/cleaning-pandas.md` | Walker + Chen recipe library — types, missing values, duplicates, normalisation |76| 4. Anomaly detection | `references/anomaly-detection.md` | IQR + z-score + Isolation Forest panel; skew-aware method selection |77| 5. Merge audit | `references/merge-discipline.md` | Walker checkmerge + Chen `validate=` cardinality; mandatory before any join |78| 6. Quality score | `references/quality-assessment-walker.md` | Four-axis composite (completeness · usefulness · reliability · relevance), default weights (0.25, 0.25, 0.30, 0.20), `passes(threshold=0.7)` gate |79| Analytics method gate | `references/analytics-quality-method-gate.md` | Descriptive / diagnostic / predictive / prescriptive method-fit gate before quantitative claims, forecasts, dashboards, or models |80| Cross-cutting | `tools/data/profiler.py` | Profile DataFrame: dtypes, distributions, cardinality, skew/kurt hints |8182## The four-axis quality score (engine's gate)8384Every dataset that ships carries a score with these axes:8586| Axis | Default weight | What it measures |87|---|---|---|88| **Completeness** | 0.25 | Missing-value rate per column; required-column presence |89| **Usefulness** | 0.25 | Required columns present; cardinality fit; type validity |90| **Reliability** | 0.30 | Source tier (`source-evaluation`) + provenance + duplicate rate |91| **Relevance** | 0.20 | Match to research topic, geographic scope, time range |9293Composite score: weighted sum. Default ship gate: composite ≥ 0.70. Lower thresholds require explicit override and reason.9495## The provenance packet (required output per dataset)9697Every dataset that survives the pipeline produces:9899```100projects/<id>/data/dataset.parquet # the cleaned data101projects/<id>/data/dataset.profile.json # profile (dtypes, distributions, cardinality)102projects/<id>/data/dataset.dq.json # four-axis quality score103projects/<id>/data/dataset.manifest.json # provenance: source, fetched_at, encoding,104 # cleaning_steps_applied, tidy_violations_fixed,105 # outliers_flagged, merge_audit, dq_score106```107108Without the manifest, the data is not shippable.109110## The non-negotiable rules1111121. **Encoding first.** No `pd.read_csv` before `references/encoding-and-unicode.md` has run. Default `encoding='utf-8-sig'`.1132. **Tidy before analysis.** Load `references/tidy-data-craft.md`; lint for the three Wickham violations; fix them.1143. **`validate=` on every merge.** Load `references/merge-discipline.md`. Default `validate='one_to_one'` or `'one_to_many'` — never default-merge.1154. **Outlier panel, not single test.** Load `references/anomaly-detection.md`. IQR for skewed; z-score for normal; Isolation Forest for high-dimensional. Consensus across 2+ methods before flag.1165. **Score before ship.** Load `references/quality-assessment-walker.md`. Composite ≥ 0.70 default; sub-axis ≥ 0.50 each.1176. **Manifest always.** No dataset ships without the provenance packet.1187. **Method fit before claims.** Load `references/analytics-quality-method-gate.md`119 before statistical tests, forecasts, dashboards, or ML models. Downgrade the claim if120 the data only supports a simpler analytics type.121122## Universal anti-patterns123124- `pd.read_csv` with no encoding repair → silent BOM-corruption of first column header.125- Cleaning before checking tidiness → fixing rows that should not exist as separate rows.126- Default `pd.merge` → silent fan-out duplication in many-to-many joins.127- Single-method outlier detection → either too strict (z-score on skewed) or too loose (IQR on multimodal).128- Quality score reported as one number without sub-axes → hides which axis failed.129- Cleaning step that drops rows without logging the reason → unrecoverable data loss.130- Manifest written by hand → drifts from actual processing.131- Reporting `n_rows` without `n_duplicates_removed`, `n_outliers_flagged`, `n_merge_orphans`.132133## Universal ship gate134135- [ ] Encoding repaired; manifest records detected encoding and BOM-stripped flag.136- [ ] Tidy check passed; violations fixed or flagged.137- [ ] Cleaning steps logged in manifest with input/output row counts.138- [ ] Outlier panel run; consensus flags exported.139- [ ] Every merge ran with `validate=`; orphan rate within threshold; fan-out factor sane.140- [ ] Four-axis score computed; composite ≥ 0.70 (or override declared with reason).141- [ ] Provenance packet written: parquet + profile.json + dq.json + manifest.json.142- [ ] Pair with `source-evaluation` reliability tier (mandatory).143144## Companion skills145146## Inputs147148| Input | Source/provider | If absent |149|---|---|---|150| Raw dataset, schema, provenance, intended analysis | Data owner and retrieval record | Stop transformation; request source and purpose |151| Quality thresholds and join keys | Analysis plan | Profile first and mark thresholds undecided |152153## Capability Contract154155Profiling is read-only by default. Cleaning, overwriting, deleting, merging, publishing, or certifying data requires explicit authority and preserved raw inputs.156157## Degraded Mode158159Without executable tools or complete metadata, return a manual profile with unassessed axes and never label the dataset clean or fit for use.160161## Decision Rules162163| Choice | Action | Failure/risk avoided |164|---|---|---|165| Encoding damage is reversible | Repair on a copy and log mapping | Silent corruption |166| Join cardinality differs from expectation | Stop merge | Row multiplication |167| Quality threshold fails | Block downstream analysis | Misleading result |168169## Data Correction Examples170171- Editing the raw file; preserve it.172- Dropping outliers automatically; investigate them.173- Merging without cardinality checks; audit keys.174- Treating blanks as zeros; preserve semantics.175- Passing an unassessed axis; mark it.176177## Data Quality Scenario178179A many-to-many join that was expected to be one-to-one stops before output and records the duplicate keys.180181## Companion skills182183- `dataset-discovery-and-analysis` — find the data before this pipeline runs.184- `source-evaluation` — reliability axis depends on this.185- `web-scraping-foundations` — when the data has to be scraped.186- `research-orchestration` — when the data is feeding a research project.187- `report-and-proposal-craft`, `academic-writing` — when the data feeds a written artifact.188189<!-- dual-compat-end -->190191## Workflow1921931. Preserve raw data, provenance, schema, intended use, and checksum.1942. Profile encoding, structure, missingness, duplicates, ranges, keys, and anomalies.1953. Stop when provenance is absent, a join violates cardinality, or a quality gate fails.1964. Recover on a copy by repairing documented defects and rerunning the affected profile.1975. Release the cleaned data, manifest, quality score, and issue register together.198199## Outputs200201| Artefact | Consumer | Acceptance condition |202|---|---|---|203| Clean dataset, manifest, profile, and issue register | Analyst and downstream workflow | Raw data is preserved and every transformation, join, exception, and unassessed axis is recorded |204205## Evidence Produced206207| Evidence | Consumer | Acceptance condition |208|---|---|---|209| Before-and-after profiles, checksum, and transformation log | Data reviewer and release owner | Results reproduce from the preserved raw input and logged operations |210211## Anti-Patterns212213- Editing the raw file. **Fix:** transform an immutable copy.214- Dropping outliers automatically. **Fix:** investigate and document disposition.215- Merging without cardinality checks. **Fix:** assert key relationships first.216- Treating blanks as zeros. **Fix:** preserve missing-value semantics.217- Passing an unassessed axis. **Fix:** mark it unassessed and block dependent claims.218219## Worked Example220221A many-to-many join expected to be one-to-one stops before output, records duplicate keys, repairs the mapping, and reruns validation.