edf.fix()
Apply automated cleaning fixes to a dataset.
Signature
edf.fix(data, *, strategy='auto', drop_duplicates=True, fill_missing='median', dry_run=False) -> FixResultApply automated cleaning fixes to a dataset.
Description
Executes an opinionated cleaning pipeline: normalises whitespace, coerces obvious dtypes, drops exact duplicates, imputes missing values with a per-column strategy, and flags rows that could not be repaired. Returns a FixResult that exposes the cleaned DataFrame, the list of applied fixes and helpers for export.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| data | str | pathlib.Path | pandas.DataFrame | — | Source dataset. Same input types as assess(). |
| strategy | Literal['auto', 'safe', 'aggressive'] | 'auto' | 'safe' only applies non-destructive fixes; 'aggressive' will drop columns with >90% missing values. |
| drop_duplicates | bool | True | Remove exact duplicate rows before imputation. |
| fill_missing | Literal['mean', 'median', 'mode', 'ffill', 'drop'] | 'median' | Per-column imputation strategy for numeric fields. |
| dry_run | bool | False | When True, computes the diff without materialising the cleaned DataFrame. |
Returns
FixResult — Wraps .dataframe, .applied_fixes, .to_csv(), .to_excel() and .diff().
Raises
ValueError— an unknown strategy or fill_missing option is passed.
Examples
Clean and export
fix_example.py
python
import eazydatafix as edf
result = edf.fix("employees.csv")
result.applied_fixes
result.to_csv("clean.csv")Python 3.11— Expected output
>>> result = edf.fix("employees.csv")>>> result.applied_fixes['strip_whitespace', 'coerce_numeric', 'drop_duplicates(6)', 'impute_missing(38, median)']>>> result.to_csv("clean.csv")wrote clean.csv (1,198 rows × 12 cols)Notes
- fix() is deterministic — the same input plus the same options produces the same output.
- Pass dry_run=True to preview which fixes would apply without touching the data.
Best Practices
- Store result.applied_fixes alongside the cleaned file so pipelines stay auditable.
- Prefer strategy='safe' for regulated workloads; keep 'aggressive' for exploratory work.