Prompt: Build a Dataset Cleaning Plan
Turns a rough description of a messy dataset into an ordered cleaning plan, listing each fix as a separate, checkable step before analysis starts.
You are a data analyst who plans data cleaning as a sequence of checkable steps before touching any analysis.
Objective: Produce a cleaning plan for the dataset described below, to prepare it for {{INTENDED ANALYSIS — e.g. a monthly revenue trend report}}.
Context: {{DATASET DESCRIPTION — e.g. a CSV export of orders with columns order_id, date, customer_email, region, amount}}. Known issues: {{KNOWN ISSUES — e.g. some dates are text, some emails are duplicated, a few amounts are negative}}.
Constraints:
- Produce exactly one numbered step per known issue listed above, in the order the issues were listed, plus exactly one final step for a post-clean validation check
- Each step must name the specific column affected and the exact action to take on it
- Do not propose deleting a row or column unless the known issue explicitly makes that row unusable; prefer a fix over a deletion where one exists
- Do not invent an issue that wasn't listed in the known issues above
Example: "convert the date column from text to a date type, using the format found in the source" is a specific step; "clean up the dates" is not.
Output format: Return a numbered list of steps, each one to two sentences, ending with the validation step described above.
Before finishing, check that the number of steps equals the number of known issues plus one, and that every step names a specific column.
Example
Input
INTENDED ANALYSIS — e.g. a monthly revenue trend report: a monthly revenue trend report DATASET DESCRIPTION — e.g. a CSV export of orders with columns order_id, date, customer_email, region, amount: a CSV export of orders with columns order_id, date, customer_email, region, amount KNOWN ISSUES — e.g. some dates are text, some emails are duplicated, a few amounts are negative: some dates are stored as text in mixed formats, some customer_email values are duplicated across rows, a few amount values are negative
Output
1. Convert the `date` column from text to a proper date type, standardising the mixed formats to a single format (e.g. YYYY-MM-DD) so rows sort and filter correctly by month. 2. Investigate duplicate values in `customer_email`: if they represent the same customer placing multiple genuine orders, keep them; if they're accidental duplicate rows for the same order, remove only the exact duplicate rows, not the customer's other legitimate orders. 3. Review rows where `amount` is negative: if these are valid refunds or returns, keep them but flag them with a new `is_refund` column rather than deleting them; only remove a row if the negative value is a clear data-entry error with no matching refund record. 4. Validate the cleaned dataset by confirming every `date` value parses as a valid date, `order_id` has no unexpected duplicates, and the count of rows removed is small relative to the original dataset size.
Why it works
- Producing one step per known issue, in the order given, keeps the plan traceable back to the specific problems that were actually reported.
- Preferring a fix over deletion by default protects real data (like genuine refunds) from being silently discarded during cleaning.
- The pre-finish check re-verifies the step count against the issue count, catching a merged or skipped step before the plan is followed.
Why the basic version fails
“Give me a plan to clean this dataset” without the specific known issues produces generic advice — “check for duplicates, handle missing values” — that doesn’t tell you which column to look at or what a fix should actually do, so you still have to work out the specifics yourself.
What this prompt fixes
Tying the plan directly to the known issues, one step each, means every step is actionable against your real data rather than being generic best-practice advice. Preferring a fix over a deletion by default is what stops an over-eager cleaning pass from silently dropping valid data, like genuine refunds recorded as negative amounts, just because it looked anomalous.
Tips per model
- ChatGPT sometimes suggests deleting rows as the fastest fix; check each deletion suggestion against whether the row is actually unusable or just unusual.
- Claude tends to flag ambiguous cases (like whether a duplicate is legitimate) rather than assuming, which is useful when you don’t yet know the answer yourself.
- List every known issue you’re aware of, even minor ones — a step is only generated for issues you actually name, so an unlisted issue won’t be addressed.