edfEazyDataFix

edf.fix()

Apply automated cleaning fixes to a dataset.

Signature
edf.fix(data, *, strategy='auto', drop_duplicates=True, fill_missing='median', dry_run=False) -> FixResult

Apply 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

NameTypeDefaultDescription
datastr | pathlib.Path | pandas.DataFrameSource dataset. Same input types as assess().
strategyLiteral['auto', 'safe', 'aggressive']'auto''safe' only applies non-destructive fixes; 'aggressive' will drop columns with >90% missing values.
drop_duplicatesboolTrueRemove exact duplicate rows before imputation.
fill_missingLiteral['mean', 'median', 'mode', 'ffill', 'drop']'median'Per-column imputation strategy for numeric fields.
dry_runboolFalseWhen True, computes the diff without materialising the cleaned DataFrame.

Returns

FixResultWraps .dataframe, .applied_fixes, .to_csv(), .to_excel() and .diff().

Raises

  • ValueErroran unknown strategy or fill_missing option is passed.

Examples

Clean and export

fix_example.py
import eazydatafix as edf

result = edf.fix("employees.csv")
result.applied_fixes
result.to_csv("clean.csv")
Python 3.11Expected 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.

See Also