Data Quality Problems
Context: FIT1043_MOC Β· the defects wrangling must fix Β· found by auditing Β· each has a detect β fix strategy
Quick Revision
- π― Objective: recognise the common data-quality issues and pair each with a detection and a fix.
- π¦ Core Components: interpretability Β· format Β· inconsistency/misspelling Β· irregularities Β· integrity violations Β· missing Β· outliers Β· duplicates.
- β‘ Key Constraint: fixing is judgement + justification β imputation vs removal, or keeping an outlier, depends on domain context, not a rule.
π How It Works
1. The Issue Types (causes)
- Interpretability β no documentation / data dictionary β canβt reliably use the fields; obtain the dictionary.
- Data format β sources differ (JSON vs XML, etc.) β hard to integrate; convert to a common format.
- Inconsistent / faulty β mistyped, inconsistent entry, extraneous data.
- Missing / incomplete, Outliers, Duplicates β see detection/fixing below.
2. Detect & Fix (worked cases)
- Inconsistency & misspelling β detect
unique(),value_counts(); fix standardise case / representation (e.g.0βNo), replace infrequent values with the best-matching frequent one. - Irregularities (invalid dates, domain-invalid like negative passengers) β detect
unique(), value ranges, type-casting (parse to datetime, catch exceptions); fix consult docs, replace, or remove. - Integrity-constraint violations (land < building size; one field = sum of others) β detect domain rules; fix swap or remove.
- Missing values β detect
unique(), value range, domain analysis (may be coded, e.g.?or*); fix imputation (mean/mode, regression viadf.corr(), dummy value) or removal β justify the choice. - Outliers β detect
df.describe()range, boxplot (IQR rule), 3Ο rule; fix as for missing values. - Duplicates β detect pick candidate keys (fix other issues first, try different keys); fix merge/combine or remove.
βοΈ Core Decision Matrix
| Problem | Detect with | Fix with |
|---|---|---|
| Inconsistency/misspelling | unique(), value_counts() | standardise; replace infrequent β best match |
| Irregularities | ranges; type-cast + catch errors | docs / replace / remove |
| Integrity violation | domain rules (context) | swap / remove |
| Missing values | unique(), ranges, domain analysis | impute (mean/mode/regression/dummy) or remove |
| Outliers | describe(), boxplot, 3Ο | impute or remove (justify) |
| Duplicates | candidate keys | merge / remove |
When It Flips: missing values and outliers share the same fix menu (impute vs remove) β the differentiator is detection, and every removal/imputation needs a domain justification.
π Exam Execution Trace
Applied Exercise
Problem: A price column has and . Which values are outliers by the IQR rule? Derivation Proof / Hand-Calculation Walkthrough:
Final Extracted Output: anything or is an outlier (so a \2{,}000{,}000$ listing flags).
π§ Active Recall
State the IQR outlier rule, and why you shouldn't auto-delete detected outliers.
- Hint: IQR bounds + judgement.
Answer
- Short answer: Outliers fall below or above (IQR ); donβt auto-remove because a βfarβ value may be genuine β fixing needs domain justification.
- Why: Detect β fix β boxplot/3Ο flag candidates; removal vs imputation is a context decision (compare detectors first).
How do you detect and fix misspelling/inconsistency in a categorical column?
- Hint: unique + frequency matching.
Answer
- Short answer: Inspect
unique()values andvalue_counts(); standardise case/representation and replace infrequent variants with the best-matching frequent value.- Why: Frequency as truth β common spellings are likely correct; rare near-matches are likely typos to merge.