Fixing
edf.fix() runs a deterministic, configurable cleaning pipeline and returns the cleaned data with an audit trail.
The default pipeline
- Normalise column names
- Trim leading and trailing whitespace
- Recognise configured missing-value markers
- Remove exact duplicate rows
- Remove empty rows and columns
- Fill missing values with the configured strategy
Configuration
Pass a FixConfig to control every cleaning stage. Use a ColumnCleaningRule when one column needs a different strategy.
fixing.py
python
import eazydatafix as edf
config = edf.FixConfig(
missing_value_strategy="median",
missing_markers=("", "NA", "N/A", "unknown"),
column_rules={
"department": edf.ColumnCleaningRule(
missing_value_strategy="mode",
),
},
)
result = edf.fix("employees.csv", config)
print(result.applied_fixes)
result.save("employees-clean.csv")Dry run
Set dry_run=True to preserve the source in result.dataset and inspect the cleaned proposal separately in result.proposed_dataset.
dry_run.py
python
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())Python 3.11
>>> preview.dry_runTrue>>> preview.dataset.shape, preview.proposed_dataset.shape((12, 8), (11, 8))Exporting
result.save() and the backwards-compatible result.to_csv()write CSV files. For Excel, export the cleaned DataFrame directly.
export_cleaned.py
python
result.save("employees-clean.csv")
result.dataset.to_excel("employees-clean.xlsx", index=False)See the reference for the complete return value and usage notes.