Friendly Clean (fc) — Proposal
A proposed batch data-cleaning command that chains multiple cleaning operations in one pass. Inspired by real data quality issues found in the practice files under 04-cleaning/.
The Problem
Real-world CSV data has recurring issues that require multiple manual steps:
| Problem | Example | Source |
|---|---|---|
| Inconsistent casing | completed, COMPLETED, Completed | 01-dirty_orders.csv |
| Negative values | -50.00 amount | 01-dirty_orders.csv |
| Non-numeric in numeric column | abc in amount | 01-dirty_orders.csv |
| Leading/trailing whitespace | common in CSVs | Various |
| Null/empty cells | blank region | 01-dirty_orders.csv |
| Duplicate rows | Alice row repeated 3x | 01-dirty_orders.csv |
| Zero values that should be null | 0.00 amount | 01-dirty_orders.csv |
| Missing emails | Carol, Grace, Kate | users.csv |
| Missing dates | blank last_login | users.csv |
Proposed Syntax
Space fc Enter # prompt: fc: <col>|* <op>[, <op> ...] [, <col> <op>...]
Operations
| Operation | What it does | Applies to |
|---|---|---|
lowercase | .lower() on text | text columns |
uppercase | .upper() on text | text columns |
trim | .strip() whitespace | all columns |
abs | abs() on numeric | numeric columns |
to-numeric | Cast to float, flag errors | numeric columns |
fill-down | Copy non-null from previous row | any column |
fill-missing | Replace empty cells with placeholder text | any column |
dedupe | Remove duplicate rows (keeps first) | all * |
zero-to-null | Replace 0 with empty | numeric columns |
strip-punctuation | Remove ,.-_/ from text | text columns |
Column targeting
Follows the same convention as fr:
| Input | Target |
|---|---|
status lowercase | Single column |
* trim | All visible columns |
amount abs to-numeric | Chained ops on same column |
status lowercase, * trim | Comma separates clauses |
status lowercase and amount abs | Cross-column via and |
Real Examples
Example 1: Clean 01-dirty_orders.csv
Raw data:
amount status region
150.00 completed sg
-50.00 completed
200.00 COMPLETED sg
abc pending jk
150.00 completed sg
shipped my
Space fc → * trim, amount abs to-numeric, status lowercase, region fill-down, * dedupe
Result:
amount status region
150.00 completed sg
50.00 completed sg
200.00 completed sg
#ERROR pending jk
150.00 completed sg
0.00 shipped my
Each step:
| Step | Before → After |
|---|---|
* trim | No visible change (whitespace stripped) |
amount abs | -50.00 → 50.00 |
amount to-numeric | abc → #ERROR (flagged) |
status lowercase | COMPLETED → completed |
region fill-down | blanks filled from previous row |
* dedupe | Alice duplicate removed |
Example 2: Clean users.csv
Space fc → email fill-missing, last_login fill-missing, * trim
- Missing emails → placeholder
no-email@unknown - Missing last_login → placeholder
never - All fields trimmed
Why It Matters
Without fc:
g*one pair at a time for text normalizationg=with Python expressions for numeric transforms- Manual navigation to each column
- No built-in
abs,fill-down, ordedupeas one-step operations
With fc:
- Chain multiple cleaning operations in one command
- Same column-targeting convention as
ffandfr - Batch undo with
U(same mechanism asfr) - No Python syntax needed
Implementation Notes
- Build as
keybind-source/38-friendly-clean.py - Each operation is a simple Python function on the cell value
- Chained operations on same column apply in order (left to right)
- Uses the same
vd.addUndo()batch-undo pattern asfr - Follows same
and/or/ comma parsing asffandfr
This is a proposal — not yet implemented. See the built commands ff (Filtering) and fr (Incremental & Replace) for the working pattern.