edf.fix()
Apply configurable, deterministic cleaning to a dataset.
Signature
edf.fix(dataset, config=None) -> FixResultApply configurable, deterministic cleaning to a dataset.
Description
Runs the v1 cleaning pipeline with an optional FixConfig. Configure missing-value handling, custom missing markers, per-column overrides, duplicate and empty-row removal, whitespace trimming and column-name normalisation. Dry runs preserve the source dataset and expose a separate proposed dataset.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| dataset | str | pathlib.Path | pandas.DataFrame | — | A pandas DataFrame or path to a supported CSV or Excel dataset. |
| config | FixConfig | None | None | Optional deterministic cleaning configuration. None uses FixConfig defaults. |
Returns
FixResult — The resulting dataset, before/after assessments, applied fixes, structured change log and optional dry-run proposal.
Raises
FileNotFoundError— the supplied path does not exist.ValueError— a cleaning strategy or input file type is unsupported.
Examples
Clean and export
fix_example.py
python
import eazydatafix as edf
config = edf.FixConfig(
missing_value_strategy="median",
missing_markers=("", "NA", "N/A", "unknown"),
)
result = edf.fix("employees.csv", config)
print(result.applied_fixes)
result.save("employees-clean.csv")Python 3.11— Expected output
>>> result = edf.fix("employees.csv", config)>>> result.applied_fixes['Trimmed leading/trailing whitespaces.', 'Removed 1 duplicate row(s).', "Filled numeric column 'salary' using median."]>>> result.save("employees-clean.csv")Preview with a dry run
Notes
- fix() does not mutate a caller-supplied DataFrame.
- In a dry run, result.dataset remains unchanged and result.proposed_dataset contains the cleaned preview.
Best Practices
- Keep result.applied_fixes and result.change_log with the cleaned output for auditability.
- Use ColumnCleaningRule entries when one column needs different missing markers or imputation.