Create beginner Works with: Any AI

Messy CSV Cleaning Plan Before Any Code

Structured brief Has example

Inspect a messy file and plan the cleaning steps.

The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.

Rate this prompt

Loading ratings…

Plan the cleaning of a messy CSV before writing any code. Pandas version and Python version: [PANDAS_AND_PYTHON_VERSION]. First 20 rows plus a description of the columns: [PASTE_SAMPLE_AND_COLUMNS]. What the cleaned data will be used for: [USE_CASE].

Work in four passes and label each:
1. Diagnosis: for every column name the probable type, the problems you can see (mixed types, trailing spaces, inconsistent case, date formats, currency symbols, thousands separators, placeholder values such as "N/A", "-", or 9999), and one check I can run to confirm it, such as df[col].map(type).value_counts() or df[col].str.strip().ne(df[col]).sum().
2. Decisions: a table with Column | Problem | Options | Recommended fix | Risk of the fix. Where a fix could destroy information (for example turning blanks into zero), say so and propose a flag column instead.
3. Order of operations: a numbered list that puts the safest steps first and explains why the order matters (for example strip text before parsing dates).
4. Validation: five assertions to run at the end (row counts, uniqueness of the key, allowed ranges, no nulls in required columns, totals that must match the source).
Do not write the cleaning code yet. End by asking which decisions I want to make before you write it.

Fill in before use

Optional: type your details and the prompt above updates. Nothing is saved or sent.

Replace each bracketed placeholder with your own details, then paste into Any AI or another assistant.

See an example result (fictional data)
Diagnosis (extract)
price: probable type float; problems: "$1,200", "N/A", trailing spaces. Check: df["price"].map(type).value_counts().
signup_date: mixed formats 03/04/2025 and 2025-04-03. Check: count values matching each pattern.
Decisions
Column | Problem | Recommended fix | Risk
price | text with symbols | strip symbols, to_numeric | blanks become NaN, keep a flag
signup_date | ambiguous | parse with day-first rule agreed with the owner | wrong month swap
Order: strip text, standardise missing markers, parse numbers, parse dates, validate.
Validation: row count unchanged; id unique; price >= 0; totals equal the source.
Question for you: should "N/A" mean unknown or zero?

Illustrative only, made-up data. Your results will differ and must be reviewed.

Related prompts