What this thread does
The problem
You hand an agent a dirty file and say "clean it". It returns something tidy, but you cannot tell which rows it dropped, which values it guessed, or whether "Inactive" and a very large revenue figure were real. The Codebasics guide ("How to Use Claude for Data Cleaning: Practical Prompts and Workflows", Codebasics Team, 10 Sep 2026) is built around avoiding that.
The workflow in the guide
Profile, identify, plan, transform, validate, document.
1. Profile first, change nothing. Ask for a table of issues (missing values, duplicates, inconsistent categories, wrong types, mixed date formats, outliers, stray whitespace, inconsistent capitalisation) with examples, impact and a recommended action, and say the data stays untouched. 2. Write the rules yourself. For example: remove exact duplicates, map country variants to one standard value, strip currency symbols from revenue, flag very large values for review. The guide's point: do not let the model invent business rules. 3. Deduplicate with review. Ask it to find exact duplicates, repeated customer IDs and near-duplicate names, delete nothing, and show the logic and pandas code for you to run separately. 4. Missing values: ask for the percentage per column, possible meanings and options (remove, replace, keep); no automatic fills or deletes. 5. Standardise and convert with explicit mapping tables, whitespace and case fixes that leave IDs alone, numeric conversion for money, date conversion that flags invalid or ambiguous dates. 6. Generate a script, not a result: it works on a copy, flags problems instead of silently dropping rows, prints before and after row and null counts, and writes the output. 7. Validate with a PASS/FAIL checklist: duplicates, nulls, types, invalid dates and categories, negative revenue, unexpected row-count change, altered or null IDs. 8. Document: a summary of row counts, transformations, flagged values and open issues.
Mistakes the guide lists
- Asking it to "clean everything", which leads to vague, unchecked assumptions.
- Letting the model make business decisions, such as deleting an unusually large value that may be a legitimate enterprise account.
- Running generated code without reading the filters, joins, replacements and date logic.
- Skipping before-and-after comparisons, so unexplained row losses go unnoticed.
- Withholding business context, so a value like "Inactive" gets misread.
Why a script, not a cleaned file
A script can be reread, rerun when next month's file arrives, and diffed. In an r/datascience post (29 Mar 2026; the author is promoting their own cleaning library, so it is a vendor view) the author says AI-generated transformation code is hard to audit and debug at scale, which is the same worry from the other side. Anthropic's xlsx skill also lists cleaning messy tabular files among its triggers, but its advice is about spreadsheets; see the thread on editing existing Excel files.
Dates and locales (my addition, not in the guide)
State the date format and decimal separator of the source ("day first, comma decimals") in the rules; otherwise 03/04 is guessed.
Caveats
This is one training-company blog with no measured results, and I have not run the prompts. The row-count and PASS/FAIL steps are cheap safeguards you can add to any cleaning script, whichever agent writes it. Fuzzy matching of names is the riskiest step: keep it as a flag for review, not an automatic merge.
Sources
Checked against the primary source: the Codebasics guide (Codebasics Team, 10 September 2026). Its framework is Profile, Identify, Plan, Transform, Validate, Document; the script requirements (work on a copy, flag invalid values instead of deleting, print before and after row and missing-value counts, save the output), the PASS/FAIL validation checklist, the summary step and the "Common Mistakes" list match the body. The article folds "identify" into profiling, and the eight numbered steps above are this thread's own regrouping of its steps and prompts.
Not checked here: the r/datascience post (not opened), the statement about Anthropic's xlsx skill triggers, and the dates and locales note, which is our addition. Nothing was run.
Started from a post by @Codebasics Team, packaged by the editor. Original post