
Data Scrubbing
- 25 installs
- 7 repo stars
- Updated May 20, 2026
- daemon-blockint-tech/agentic-enteprises-skill
Cleans and standardizes tabular datasets: profiling, quality rules, missing values, duplicates, outliers, type coercion, and record linkage.
About
An agent skill for cleaning and standardizing tabular datasets before analysis or modeling, covering profiling, quality rules, missing values, duplicates, outliers, encoding fixes, and record linkage. A developer uses it when scrubbing data, deduping records, handling missing values, or preparing data for modeling.
- Deduplication, outlier treatment, and reproducible scrub pipelines
- Validation checks and high-level PII handling
Data Scrubbing by the numbers
- 25 all-time installs (skills.sh)
- Ranked #1,157 of 2,064 Data Science & ML skills by installs in the Skillselion catalog
- Data as of Jul 29, 2026 (Skillselion catalog sync)
npx skills add https://github.com/daemon-blockint-tech/agentic-enteprises-skill --skill data-scrubbingAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 25 |
|---|---|
| repo stars | ★ 7 |
| Last updated | May 20, 2026 |
| Repository | daemon-blockint-tech/agentic-enteprises-skill ↗ |
What it does
Cleans and standardizes tabular datasets: profiling, quality rules, missing values, duplicates, outliers, type coercion, and record linkage.
Files
Data Scrubbing
When to Use
- Profile a table or file and define data-quality rules before analysis or modeling
- Clean, standardize, dedupe, or link records in CSV, Parquet, SQL extracts, or notebook pipelines
- Treat missing values, duplicates, outliers, types, encodings, and column naming consistently
- Document a reproducible scrub pipeline with validation checks and sign-off criteria
- Scrub actuarial/insurance fields (policy keys, claims triangles, exposure bases) for downstream reserving or pricing prep
- Flag or redact PII at a technical level before sharing extracts (coordinate with compliance for legal requirements)
When NOT to Use
- Star/snowflake modeling, warehouse ETL/ELT, CDC, or platform ingestion design →
data-warehouse-engineer - Predictive modeling, A/B tests, causal inference, feature engineering for ML, or MLOps →
data-scientist - Loss development, IBNR, pricing models, or appointed-actuary sign-off →
actuary - Assumption sets, governance memos, or model assumption workshops →
assumption-setting - SOC 2 / ISO control mapping, audit evidence automation, or privacy legal program →
compliance-engineer - Cloud cost allocation, FinOps dashboards, or unit economics only →
finops-analyst - Spreadsheet formula integrity or cell-level model audit without a scrub pipeline →
audit-xls(if available)
Related skills
| Need | Skill |
|---|---|
| Dimensional modeling, ETL/ELT, warehouse SQL performance | data-warehouse-engineer |
| ML modeling, experiments, production model monitoring | data-scientist |
| Reserving, triangles, IBNR, pricing actuarial methods | actuary |
| Assumption documentation and governance | assumption-setting |
| Technical compliance controls and audit evidence | compliance-engineer |
| Cloud spend attribution and cost optimization | finops-analyst |
| Enterprise data governance and catalog design | data-architect |
| Analytics engineering (dbt layers, mart tests) | analytics-data-engineer |
Core Workflows
1. Intake and scope
1. Identify source(s), grain, primary keys, and downstream consumer (report, model, regulatory filing) 2. Record business definitions for critical fields and acceptable quality thresholds 3. Choose deliverables: scrubbed dataset, rule catalog, pipeline code, validation report, sign-off checklist 4. Confirm what must not change (audit trail, raw landing zone immutability)
See `references/data_scrubbing_scope_and_workflow.md`.
2. Profile and define quality rules
1. Run structural profile: row/column counts, types, null rates, cardinality, min/max, patterns 2. Classify columns: identifier, measure, dimension, date, free text, PII-sensitive 3. Draft rules: uniqueness, referential checks, range/domain, regex, cross-field logic, volume gates 4. Prioritize rules by severity (blocker vs warning) and tie each to a remediation action
See `references/profiling_and_quality_rules.md`.
3. Remediate missing values, duplicates, outliers
1. Apply documented strategies per column (impute, flag, drop, split, business rule) 2. Deduplicate at correct grain; preserve lineage for merged records 3. Treat outliers with explicit policy (cap, winsorize, exclude, investigate)—never silent deletion 4. Re-run profile deltas after each major remediation pass
See `references/missing_duplicates_and_outliers.md`.
4. Standardize and coerce types
1. Normalize names, units, currencies, time zones, and categorical vocabularies 2. Coerce types with explicit parse rules and quarantine rows that fail 3. Fix encoding (UTF-8), delimiters, locale-specific decimals, and boolean sentinels 4. Version mapping tables (code → label) alongside the pipeline
See `references/standardization_and_type_coercion.md`.
5. PII and governance (technical, not legal advice)
1. Inventory sensitive columns; classify using organizational taxonomy when provided 2. Apply minimization: drop, hash/tokenize, mask, or aggregate per approved pattern 3. Log scrub actions; restrict outputs; never commit secrets or production PII to public repos 4. Escalate legal basis, retention, and cross-border rules to compliance-engineer / counsel
See `references/pii_redaction_and_governance.md`.
6. Actuarial / insurance scrubbing
1. Validate policy/claim keys, effective/accident dates, and triangle orientation 2. Align exposure bases and earned premium logic with documented definitions 3. Scrub large losses, sublimits, and reinsurance fields without distorting triangle structure 4. Hand off reserving/pricing math to actuary after data is signed off for modeling
See `references/actuarial_insurance_data_scrubbing.md`.
7. Validate, document, sign off
1. Execute rule suite on scrubbed output; compare to thresholds and prior period if applicable 2. Produce validation report: pass/fail counts, quarantine volume, top failure reasons 3. Package reproducible pipeline (script/SQL/notebook), config, and rule catalog with version hash 4. Obtain owner sign-off before promoting to modeling or reporting consumers
See `references/data_scrubbing_scope_and_workflow.md` (sign-off section).
When to load references
| Topic | Reference |
|---|---|
| Scope, workflow, sign-off | references/data_scrubbing_scope_and_workflow.md |
| Profiling and quality rules | references/profiling_and_quality_rules.md |
| Missing, duplicates, outliers | references/missing_duplicates_and_outliers.md |
| Standardization and types | references/standardization_and_type_coercion.md |
| PII and governance | references/pii_redaction_and_governance.md |
| Actuarial / insurance data | references/actuarial_insurance_data_scrubbing.md |
Actuarial and Insurance Data Scrubbing
Purpose
Prepare insurance and actuarial tabular inputs—policies, claims, premiums, exposures—for reserving, pricing, experience studies, and management reporting. Scrubbing ensures correct grain, keys, and field semantics; reserve math and assumption selection belong to actuary and assumption-setting.
Common datasets
| Dataset | Typical grain | Scrub focus |
|---|---|---|
| Policy admin | policy × term segment | keys, dates, earned logic inputs |
| Claims | claim or claim-feature | status, amounts, linkage to policy |
| Premium | transaction or earned monthly | written vs earned, cancellations |
| Exposure | exposure unit × period | base definition, audit vs stat |
| Claims triangle | accident year × development lag | orientation, completeness |
| Reinsurance ceded | treaty × layer | attachment, limits, recoverables |
Policy fields
Validate and standardize:
| Field | Checks |
|---|---|
policy_id | Unique at intended grain; no float cast |
effective_date / expiration_date | effective <= expiration; open policies flagged |
line_of_business | Maps to approved LOB table |
state / country | Valid codes; aligns with filing territory rules |
status | In-force, cancelled, expired—mutually consistent with dates |
premium components | Written vs return premium; fees separated if required |
Document mid-term endorsements: grain may be policy segment not static policy row.
Claims fields
| Field | Checks |
|---|---|
claim_id | Unique; stable across development |
loss_date / report_date / close_date | Logical ordering |
incurred / paid / reserve | Non-negative except documented adjustments |
claim_status | Open/closed aligns with close_date |
cause_of_loss | Domain list; map legacy codes |
| Large losses | Flag above threshold; do not drop without actuary direction |
Subrogation and salvage: separate columns; do not net into incurred without specification.
Premium and earning
Scrub inputs to earned premium logic, not the actuarial formula itself:
- Identify cancellation timing and return premium rows
- Separate audit vs written premium when both exist
- Align policy term with earning pattern (pro-rata, short-rate) via metadata flags
Hand off earned calculations to actuary when actuarial standard required.
Exposure bases
Exposure must match rating variable definition:
| Line | Examples |
|---|---|
| Auto | car years, mileage band |
| GL | payroll, sales, units |
| Property | TIV, location count |
Checks:
- Exposure period aligns with policy term
- Units match filing manual (no mixed units in one column)
- Zero exposure with positive premium flagged
Claims triangles
Before triangle construction:
1. Confirm orientation: rows = accident period, cols = development lag (or document transpose) 2. Consistent valuation date for all cells 3. Exclude incomplete latest diagonal only with documented rule 4. Handle negative development from corrections via adjustment rows, not silent cell edits 5. Reconcile triangle totals to claim register control
Route triangle methodology and tail selection to actuary.
Reinsurance
| Field | Checks |
|---|---|
| Treaty ID | Maps to contract master |
| Layer attachment / limit | Numeric consistency |
| Ceded % | Between 0 and 1 (or 0–100 with documented scale) |
| Recoverables | Tie to claim keys where applicable |
Catastrophe and large loss
- Tag CAT codes separately from attritional
- Do not cap CAT losses in scrub without explicit modeling policy
- Geographic coordinates: validate range; generalize if PII concern
Experience study prep
For ratemaking experience:
- Align policy year / accident year definitions
- Filter to target segment after documenting exclusion counts
- On-level factors: store indices in versioned tables, not ad hoc spreadsheet columns
- Credibility weights: compute in actuarial workflow, not hidden in scrub
Coordination with peers
| Need | Skill |
|---|---|
| IBNR, chain ladder, tail factors | actuary |
| Assumption memos and governance | assumption-setting |
| P&C product coverage context | property-casualty-insurance |
| Pension fund specifics | pension-retirement-funds |
| Regulatory control evidence | compliance-engineer |
Sign-off (actuarial data)
Additional gates before actuary modeling:
- [ ] Triangle/register reconciliation within tolerance
- [ ] LOB and state mapping signed by actuarial data owner
- [ ] Large loss and CAT flags reviewed
- [ ] Development lag completeness documented
- [ ] Known reformations (COVID, rate changes) flagged by period
Anti-patterns
- Mixing accident year and policy year in one column without label
- Dropping open claims to "clean" triangles
- Applying loss development factors during scrub (belongs in modeling)
- Changing historical earned premium without restatement flag
- Using scrubbed triangle for regulatory filing without actuary review
Data Scrubbing — Scope and Workflow
Purpose
Data scrubbing prepares analysis-ready tabular data: consistent types, trustworthy keys, documented transformations, and measurable quality. It sits after extraction and before modeling, BI, or regulatory submissions—not at warehouse platform design.
In scope
| Activity | Outcome |
|---|---|
| Structural profiling | Null rates, cardinality, type inference, pattern samples |
| Rule definition | Uniqueness, domain, referential, volume, cross-field logic |
| Remediation | Missing, duplicate, outlier, encoding, standardization |
| Record linkage | Deterministic + probabilistic dedupe with match scores |
| Pipeline documentation | Config, version, inputs/outputs, quarantine tables |
| Validation & sign-off | Rule results, thresholds, approver attestation |
Out of scope (route to peers)
| Activity | Peer skill |
|---|---|
| Star schema, SCD, incremental warehouse loads | data-warehouse-engineer |
| Algorithm selection, training, hyperparameters | data-scientist |
| Triangle fitting, IBNR, credibility | actuary |
| SOC 2 evidence, legal privacy program | compliance-engineer |
End-to-end workflow
Intake → Profile → Rule catalog → Remediate (iterative) → Validate → Sign-off → HandoffPhase 1 — Intake
Capture in a one-page scrub charter:
- Sources: files, tables, APIs; refresh cadence
- Grain: one row per what (transaction, policy-month, claim)
- Keys: natural vs surrogate; composite keys
- Consumers: analyst, actuary, ML, regulator
- Constraints: immutability of raw layer, retention, PII policy
- Success metrics: max null rate, duplicate rate, rule pass rate
Phase 2 — Profile (baseline)
Minimum profile artifacts:
1. Row count and byte size 2. Per-column: type, null %, distinct count, top values (capped) 3. Numeric: min, max, mean, percentiles (as appropriate) 4. Date: min, max, future-dated count 5. Text: max length, encoding issues, leading/trailing whitespace rate
Store baseline profile with dataset version ID.
Phase 3 — Rule catalog
For each rule assign:
| Field | Example |
|---|---|
rule_id | POLICY_KEY_UNIQUE |
severity | blocker / warning |
expression | SQL, Great Expectations, or pseudocode |
owner | data steward name |
remediation | quarantine, fix script, manual ticket |
Phase 4 — Remediate (iterative)
Order of operations (default—adjust when domain requires):
1. Encoding and delimiter fixes 2. Type coercion and parsing quarantine 3. Standardization (codes, units, time zones) 4. Key construction and referential fixes 5. Duplicate resolution / linkage 6. Missing value treatment 7. Outlier treatment (last—after types stable)
Log every transformation in a change log table: step, rows_in, rows_out, rows_quarantined, timestamp.
Phase 5 — Validate
Re-run full rule suite on scrubbed output. Compare to baseline profile:
- Unexpected null spikes
- Cardinality collapse (over-deduping)
- Distribution shift beyond agreed tolerance
Phase 6 — Sign-off
Sign-off package (minimum):
1. Scrub charter (updated) 2. Rule catalog with final pass rates 3. Validation report (blockers = 0 unless waived) 4. Pipeline artifact hash / git commit 5. Sample row diff (before vs after) for critical fields 6. Named approver and date
Waivers: document rule ID, business justification, expiry, and compensating control.
Reproducibility requirements
- Pin random seeds where imputation or sampling is used
- Store mapping tables (e.g., state code → region) in version control
- Parameterize paths and dates; no hard-coded production secrets
- Separate raw, staging scrub, and published zones when possible
Handoff checklist
Before passing to data-scientist or actuary:
- [ ] Grain documented and verified
- [ ] Primary keys unique at stated grain
- [ ] Critical measures non-null above threshold
- [ ] Date fields parsed and time zone documented
- [ ] PII minimized per policy
- [ ] Validation report attached
- [ ] Known limitations listed (coverage gaps, manual fixes)
Anti-patterns
- Scrubbing in the only copy of production data without backup
- Dropping rows without quarantine or counts
- Changing keys without lineage to source records
- One-off Excel edits without reproducible pipeline
- Mixing scrub and model training in the same undocumented notebook cell block
Missing Values, Duplicates, and Outliers
Missing values
Classify missingness first
| Pattern | Interpretation | Typical action |
|---|---|---|
| MCAR | Random | Simple impute or drop with care |
| MAR | Explained by observed fields | Model-based or group impute |
| MNAR | Related to hidden value | Domain rule; do not blind impute |
Document assumption in scrub charter; escalate structural MNAR to domain owner.
Treatment options (choose explicitly per column)
| Strategy | Use when | Risk |
|---|---|---|
| Leave null | Optional field; model handles missing | Downstream breakage if undeclared |
Flag column (was_imputed) | Audit trail required | Wider schema |
| Constant sentinel | Legacy compatibility only | Confuses with real values |
| Group statistic impute | Stable categories | Bias if MNAR |
| Forward/back fill | Time series at entity grain | Leakage across entities |
| Drop row | Low volume, invalid grain | Selection bias |
| Business rule fill | Known derivations | Needs sign-off |
Default: prefer flag + impute over silent fill for fields used in modeling.
Missing value workflow
1. Report null rate by column and segment (product, region, year) 2. Cross-tab nulls across related fields (co-missing patterns) 3. Select strategy per column with written rationale 4. Apply in reproducible step; quarantine rows that fail derivation 5. Re-profile null rates; attach before/after table
Duplicates
Define grain before deduping
Example grains:
- Customer: one row per
customer_id - Policy-month:
policy_id+calendar_month - Claim:
claim_id(not claim line unless line grain intended)
Deduping at wrong grain destroys information or leaves hidden duplicates.
Duplicate types
| Type | Detection | Resolution |
|---|---|---|
| Exact duplicate | Hash all columns or business subset | Keep one; log count removed |
| Key duplicate | Same PK, different attributes | Survivorship rules |
| Fuzzy duplicate | Similar name/address | Linkage score + review queue |
| Cross-source duplicate | Same entity, different IDs | Master ID assignment |
Survivorship rules (deterministic)
When multiple rows share a key, pick winner by ordered criteria:
1. Most recent updated_at 2. Source system precedence (e.g., core admin > portal) 3. Most complete record (fewest nulls on critical fields) 4. Manual override table
Document merged-field logic: non-key fields may use COALESCE priority list.
Record linkage (fuzzy)
High-level steps:
1. Standardize blocking keys (soundex, postal, phone digits) 2. Generate candidate pairs within blocks 3. Score pairs (Fellegi-Sunter, ML classifier) 4. Auto-merge above high threshold; queue medium for review 5. Never auto-merge below low threshold
Preserve source_ids[] and match_score on golden record.
Outliers
Distinguish outlier types
| Type | Example | Action |
|---|---|---|
| Data error | Negative age | Fix or quarantine |
| Valid extreme | CAT loss | Keep; optional cap flag |
| Fraud / anomaly | Impossible combo | Route to investigation |
| Structural change | New product mix | Segment; do not global drop |
Detection methods (use multiple)
- IQR / z-score on log-transformed positives
- Percentile caps (p99.5) for reporting views only
- Business caps (max claim by line of business)
- Multivariate (isolation forest) for anomaly flags, not silent drops
Treatment policies (document one per measure)
| Policy | Effect |
|---|---|
| Investigate | Export to exceptions; no change until reviewed |
| Cap / winsorize | Replace with bound; add was_capped flag |
| Exclude from modeling sample | Keep in full ledger |
| Transform | log1p for skew; document inverse for interpretation |
Never remove outliers without counts, flags, and approver awareness for material fields.
Combined workflow diagram
Profile nulls → classify → impute/flag/quarantine
↓
Profile dupes at grain → survivorship / linkage → golden table
↓
Profile distributions → outlier flags → cap/investigate/keep
↓
Re-validate keys and rule suiteMetrics to report
| Metric | Formula / note |
|---|---|
| Null rate delta | After − before per column |
| Duplicate rate | 1 - distinct_keys / rows at grain |
| Rows quarantined | By reason code |
| Outlier flag rate | % rows flagged per measure |
| Imputation rate | % filled per column |
Handoff notes for modeling
Tell data-scientist explicitly:
- Which fields were imputed and how
- Whether outliers were capped or excluded from training slice
- Dedup grain and survivorship order
- Any MNAR concerns on target variable
Tell actuary explicitly:
- Whether large losses were capped or segmented
- Triangle completeness after claim dedupe
- Exposure adjustments applied before scrub sign-off
PII Redaction and Governance (Technical)
Not legal advice. This reference covers technical patterns for minimizing sensitive data in scrub pipelines. Legal basis, retention, DPA terms, and regulatory filings require compliance-engineer and qualified counsel.Goals
- Reduce exposure of personally identifiable information (PII) and sensitive categories in datasets used for analytics, modeling, or sharing
- Maintain usefulness where possible via aggregation, tokenization, or separation of keys
- Leave audit trail of what was redacted and how
PII inventory (minimum)
For each column, record:
| Field | Value |
|---|---|
| Column name | member_email |
| Category | direct identifier / quasi-identifier / sensitive |
| Regulatory tag | e.g., GDPR personal data (org taxonomy) |
| Required for use case? | yes / no |
| Approved treatment | mask / hash / drop / aggregate |
Use organizational data catalog when available; do not invent legal categories.
Common PII categories (technical)
| Category | Examples | Typical treatment |
|---|---|---|
| Direct identifiers | name, email, phone, government ID | drop or tokenize |
| Quasi-identifiers | ZIP, DOB, gender, rare job title | generalize or suppress |
| Financial account | bank account, card PAN | drop; never log |
| Health (PHI) | diagnosis codes in some contexts | strict minimization; legal review |
| Online identifiers | cookie ID, device ID | hash with salt if needed |
Treatment patterns
Removal
Drop column from derivative datasets when not needed. Simplest and lowest risk.
Masking
Partial display for operational support only:
- Email:
j***@domain.com - Phone: show last 4 digits
Not sufficient for open analytics datasets.
Hashing / tokenization
token = HMAC-SHA256(pepper, normalized_value)Requirements:
- Use organization-approved pepper/secret store (env var, KMS)—never commit pepper
- Normalize before hash (lower email, strip phone formatting)
- Same input → same token enables joins within environment
- Salting per environment prevents cross-env linkage
Generalization
| Field | Generalization |
|---|---|
| DOB | birth year or age band |
| ZIP | 3-digit prefix (US) where policy allows |
| Date | month-start only |
Aggregation
Publish cohort-level stats only; suppress small cells (n < k).
Pseudonymization vs anonymization
| Term (technical) | Meaning |
|---|---|
| Pseudonymized | Reversible with key; still often regulated |
| Anonymized | No reasonable re-identification; expert determination required |
Do not label output "anonymized" without organizational sign-off.
Pipeline controls
1. Separate environments: scrub in non-prod; restrict prod exports 2. Least privilege: pipeline service account reads only required columns 3. Logging: log rule IDs and counts, not raw PII values 4. Output scanning: run pattern detectors on sample exports (email regex, SSN patterns) 5. Secure quarantine: encrypted store for rows held for investigation
Sharing externally
Before third-party transfer:
- Confirm contract and purpose limitation with legal/compliance
- Strip or tokenize per data sharing agreement
- Document schema and transformation version sent
Route SOC 2 / ISO evidence of controls to compliance-engineer.
Coordination table
| Question | Route to |
|---|---|
| Lawful basis, DPIA, DSR delete workflows | compliance-engineer, counsel |
| Enterprise retention schedule | data-architect, compliance |
| Catalog and classification taxonomy | data-architect |
| Technical scrub implementation | this skill |
Detection helpers (non-exhaustive)
Pattern-based scans (tune per locale):
- Email: RFC-like regex on sample
- Phone: E.164 length checks
- SSN (US):
###-##-####with invalid area filters - Credit card: Luhn check on digit runs
Flag columns for review; do not auto-delete without rule approval.
Documentation for audit
Include in scrub package:
- PII column list and treatment per column
- Hash algorithm and key management reference (not the secret)
- Sample of masked output
- Count of rows in quarantine for failed redaction
Anti-patterns
- Committing production extracts to git or public buckets
- Logging full row on parse errors
- Using reversible encoding (base64) and calling it encrypted
- Sharing dedupe keys across partners without agreement
- Assuming k-anonymity without formal analysis
Profiling and Quality Rules
Profiling goals
Profiling answers: what is in the dataset, where it breaks expectations, and what must be fixed before use. Treat profiling as a versioned artifact, not a one-time print statement.
Structural profile
| Dimension | Checks |
|---|---|
| Volume | Row count, file splits, partition coverage |
| Schema | Column names, order drift vs prior version |
| Types | Inferred vs declared; mixed-type columns |
| Keys | Uniqueness at claimed grain; duplicate key rate |
| Time | Coverage gaps, future dates, timezone consistency |
| Referential | Orphan FKs, unmatched dimension codes |
Statistical profile (tabular)
For numeric columns:
- Central tendency and spread (mean, median, std, IQR)
- Zero-inflation rate
- Negative values where only positive expected
- Spike detection vs prior period (%, not only absolute)
For categorical columns:
- Cardinality vs expectation
- Rare level concentration (long tail)
- Unknown / OTHER bucket size
For text columns:
- Length distribution
- Regex pattern match rate (email, phone, postal)
- Non-printable character rate
Column classification
| Class | Typical rules |
|---|---|
| Identifier | Unique, non-null, stable format |
| Foreign key | Exists in parent, null rate bounded |
| Measure | Range, non-negative, unit consistency |
| Dimension | Domain list, no leading/trailing space |
| Date / datetime | Parseable, logical ordering |
| Free text | Length cap, PII scan trigger |
| Derived | Document formula; cross-check to inputs |
Rule severity model
| Severity | Meaning | Default action |
|---|---|---|
| Blocker | Unusable for stated purpose | Fail pipeline; no publish |
| Warning | Degraded quality | Publish with flag; ticket |
| Info | Observability only | Log only |
Rule pattern catalog
Uniqueness
COUNT(*) = COUNT(DISTINCT primary_key) -- at grain GDocument composite keys explicitly (e.g., policy_id + effective_date).
Completeness
null_rate(column) <= thresholdDifferent thresholds for optional vs required fields.
Domain / validity
- Enumerated lists (status in {A,B,C})
- Range checks (
0 <= loss_ratio <= 5with business cap) - Regex (
^[A-Z]{2}[0-9]{9}$for internal IDs)
Consistency (cross-field)
effective_date <= expiration_datepaid_amount <= incurred_amount(unless documented exception)country_codealigns withcurrencywhen both present
Referential integrity
child.foreign_key IN parent.primary_keyAllow orphan rate threshold with quarantine export.
Volume and freshness
- Row count within
%of trailing average max(event_timestamp)within SLA of clock
Distribution drift (monitoring)
Compare scrubbed output to prior period:
- PSI or simple bucket shift for key measures
- New categorical levels above rate threshold
Rule implementation options
| Approach | When |
|---|---|
| SQL assertions in warehouse | Large tables, scheduled jobs |
| Great Expectations / Soda / dbt tests | Team standard, CI integration |
| pandas/polars scripts | Ad hoc files, prototypes |
| Custom YAML rule catalog | Multi-source, shared vocabulary |
Pick one primary framework per pipeline; avoid duplicate conflicting rules.
Rule documentation template
rule_id: CLAIM_AMOUNT_NON_NEGATIVE
severity: blocker
grain: claim_id
description: Incurred amount must be >= 0 unless adjustment_type = 'reversal'
expression: |
incurred_amount >= 0 OR adjustment_type = 'reversal'
remediation: quarantine to exceptions.claim_amount
owner: claims_data_stewardProfiling outputs
Deliver at minimum:
1. Profile summary (HTML/Markdown or notebook export) 2. Column-level stats (CSV/Parquet for tooling) 3. Failed rule summary with top offending values 4. Quarantine row extract (sample + full if small)
Prioritization
When time-boxed, fix in order:
1. Key integrity and grain errors 2. Blocker domain violations on measures used in models 3. Referential breaks affecting joins 4. Warnings on optional attributes 5. Cosmetic standardization
Integration with scrub pipeline
raw → profile_raw → apply_rules(staging) → quarantine → profile_scrubbed → validate → publishNever publish when blocker count > 0 unless an approved waiver exists on file.
Standardization and Type Coercion
Objectives
Standardization makes columns comparable, joinable, and machine-parseable without changing business meaning. Coercion applies explicit parse rules; failures go to quarantine—not silent coercion to null.
Naming conventions
| Element | Convention (example) |
|---|---|
| Column names | snake_case, no spaces |
| Booleans | is_active, has_reinsurance |
| Dates | suffix _date (date only) or _at (timestamp) |
| IDs | suffix _id; never reuse for different entities |
| Amounts | suffix _amount + currency_code column |
Maintain a data dictionary synced with scrub pipeline version.
Categorical standardization
1. Trim whitespace; collapse internal double spaces 2. Upper or lower case per org standard (often upper for codes) 3. Map synonyms via versioned lookup:
| raw_value | standard_code |
|---|---|
Calif. , CA , california | CA |
4. Route unmapped values to UNKNOWN quarantine bucket with count threshold alerts
Numeric standardization
- Remove thousands separators and currency symbols before parse
- Store amounts as decimal type with explicit scale
- Separate amount and currency; convert FX in dedicated step with rate table version
- Document unit multipliers (thousands vs units)
Date and time
| Issue | Fix |
|---|---|
| Mixed formats | Specify strftime patterns; try ordered parsers |
| Ambiguous MDY/DMY | Require source metadata or reject |
| Time zone | Normalize to UTC or stated zone; store offset |
Sentinels (9999-12-31) | Map to null or open_ended flag |
Validate: birth_date <= transaction_date where applicable.
Boolean coercion
Normalize sentinels to true/false/null:
| Raw | Standard |
|---|---|
Y, Yes, 1, T | true |
N, No, 0, F | false |
`, NA, Unknown` | null |
Type coercion order
1. Read as string (preserve leading zeros on IDs) 2. Apply ID rules: strip only whitespace; no numeric cast for policy numbers with leading zeros 3. Parse dates with explicit formats 4. Parse decimals with locale rules 5. Cast integers only when domain confirms integral 6. Quarantine rows failing parse with parse_error reason
Encoding and file hygiene
- Enforce UTF-8 on export; detect BOM
- Replace curly quotes and non-breaking spaces in text fields
- Normalize line endings in CSV ingestion
- Escape delimiters consistently in outputs
Geographic and industry codes
Use standard code lists where applicable:
- ISO country / currency
- NAIC / LOB codes (insurance) per org reference
- Postal formats validated by country-specific regex
Keep code tables under version control with effective dates.
Record linkage prep (standardization for matching)
| Field | Normalization |
|---|---|
| Name | Upper, remove punctuation, token sort optional |
| Address | USPS-style abbreviations if US |
| Phone | E.164 digits only |
| Lower, trim | |
| DOB | ISO date |
Do not over-normalize away discriminative tokens needed for match quality.
Derived fields
Document formulas in scrub spec:
earned_premium = written_premium * earned_ratioValidate derived fields against source components on sample.
Versioning mapping tables
Each lookup CSV/SQL table includes:
mapping_versioneffective_from/effective_toapproved_by
Pipeline records which mapping version ran.
Validation after coercion
| Check | Purpose |
|---|---|
| Type assertion | Column dtypes match dictionary |
| Parse failure rate | Below threshold |
| Referential | Codes exist in master |
| Reconciliation | Row sums match control totals |
Tools (non-prescriptive)
| Tool | Role |
|---|---|
| pandas / polars | File scrub, prototypes |
SQL CAST / TRY_CAST | Warehouse staging |
| Great Expectations | Type and parse expectations |
| OpenRefine | Interactive cleanup (export rules to pipeline) |
Promote interactive fixes to scripted steps before production sign-off.
Anti-patterns
- Casting SSN/policy numbers to float (precision loss)
- Implicit locale in
to_datetimewithout format - Mixing
NULLand empty string without policy - Applying global title-case to codes
- Hard-deleting rows that fail parse without quarantine