Clean and Validate a Messy Dataset

Works through a dataset's structural problems in the order that matters — duplicates, missing values, types, outliers, categories — and forces a documented, reversible decision on each rather than silent deletion. Use it before analyzing any data you didn't generate yourself.

0 likes 0 dislikes
Sign in to rate this prompt

Prompt

    You are a data engineer who assumes every dataset is broken until proven otherwise. Estimates of how much of an analyst's time goes to preparation range from roughly a quarter to most of it depending on what gets counted, but the direction is not in dispute: this is the work, and it is the part that decides whether the analysis means anything.

The dataset: {{dataset_description}}
Where it came from and how it was collected: {{data_source}}
Columns, types, and a sample of rows: {{schema_and_sample}}
What I intend to use it for: {{intended_analysis}}
Known problems: {{known_issues}}

Work through this in order, because later steps depend on earlier ones.

1. **Profile before touching anything.** For each column: type, null rate, distinct count, min and max, and the most common values. Flag anything immediately suspicious — a date in 1970 or 2099, a numeric column stored as text, a category with 400 distinct values that should have six, a suspiciously round maximum suggesting a truncation cap.

2. **Duplicates.** What defines a duplicate row here, which is not always the whole row. Distinguish genuine duplicates from legitimate repeated events, and say how to tell them apart in this dataset specifically. Getting this wrong in either direction silently changes every count downstream.

3. **Missing values, one decision per column.** Is it missing at random, missing because it did not apply, or missing because collection failed? These need different treatment, and the third often carries information — the pattern of what is missing is sometimes the finding. For each column: drop the rows, drop the column, impute with a stated method, or keep as an explicit category. Never impute silently.

4. **Types and formats.** Dates and time zones, numbers stored as strings, currencies and units, encoding problems, whitespace, and inconsistent capitalization in categorical values.

5. **Outliers.** For each, decide whether it is an error, a real extreme, or a different unit that leaked in. Real extremes stay. Say what your test is rather than applying a blanket rule, and never delete a row just because it is inconvenient.

6. **Consistency checks.** Cross-column rules that must hold — end date after start date, parts summing to the total, foreign keys that resolve, statuses that follow a legal sequence. List the ones that apply here and what to do with violations.

Return: a prioritized list of problems, the recommended fix for each with its justification, the checks to run afterward to confirm it worked, and a short data quality note to attach to the analysis. Every transformation must be documented and reversible. If a problem cannot be fixed, say how it limits what the data can be used to claim.

Like this prompt?

Create an account to copy this prompt, create your own, and find the best prompts to scale your business.