edf.fix()

Apply configurable, deterministic cleaning to a dataset.

Signature
edf.fix(dataset, config=None) -> FixResult

Apply 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

NameTypeDefaultDescription
datasetstr | pathlib.Path | pandas.DataFrameA pandas DataFrame or path to a supported CSV or Excel dataset.
configFixConfig | NoneNoneOptional deterministic cleaning configuration. None uses FixConfig defaults.

Returns

FixResultThe resulting dataset, before/after assessments, applied fixes, structured change log and optional dry-run proposal.

Raises

  • FileNotFoundErrorthe supplied path does not exist.
  • ValueErrora cleaning strategy or input file type is unsupported.

Examples

Clean and export

fix_example.py
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.11Expected 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

fix_example.py
config = edf.FixConfig(dry_run=True)
preview = edf.fix("employees.csv", config)

print(preview.dry_run)
print(preview.change_log)
print(preview.proposed_dataset.head())

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.

See Also