The best ChatGPT prompts for data analysis describe the data precisely, state one business question, and ask for code plus the assumptions that could make the answer wrong. Below are 14 prompts for ChatGPT, Claude and Codex that take you from a raw file to a checked result: first look, cleaning, joins, SQL and pandas, charts, statistics sanity checks and a summary people will read.
For query tuning and schema work, see the separate SQL prompts. For spreadsheet formulas, see the Excel formula prompts.
How to use these prompts
Copy a prompt, then replace the blanks in double braces, or keep the default after the colon: {{tool:pandas}} means pandas unless you change it.
Four habits matter more than wording:
- Describe the data, don't just attach it. Give column names, types, the row count and what one row represents. Models misread grain ("one row per order" versus "one row per order line") more than anything else.
- Paste a small sample. Ten rows that include the messy cases (blanks, odd dates, duplicates) beat a thousand clean ones.
- Ask for code, not just answers. Code you can rerun is checkable. A number in a chat reply is not.
- State your versions. pandas 3.0 changed defaults: strings now get a dedicated
strdtype, and chained assignment stops working. Say which version you run.
How do you explore a new dataset with ChatGPT?
1. First look at a new dataset
Run this before any analysis. It surfaces the problems that would quietly break everything later.
I have a dataset I haven't worked with before. Help me understand it before I analyze anything.
What one row represents: {{grain:one order}}
Columns and types:
{{columns}}
Sample rows:
{{sample}}
Write {{tool:pandas}} code that shows: the shape, dtypes, missing values per column, describe(include="all"), the top values of each text column, and the min and max of every date. Then list what I should check next: likely ID columns, columns that look like the wrong type, and anything that suggests the grain isn't what I said.
2. Turn a vague request into analysis questions
For when a stakeholder asks "can you look into churn?"
My manager asked: "{{request:Why did revenue drop last quarter?}}"
Data I have: {{data_description}}
Turn this into 3 to 5 specific questions the data can answer. For each: the metric, the breakdown, the time window, and the chart that would answer it. Then list questions the data can't answer and what extra data would be needed.
How do you clean messy data with pandas?
3. Load a messy CSV correctly
Most cleaning problems start at load time. The read_csv docs cover dtype, na_values, thousands, parse_dates and date_format, which handle most of them.
Write pandas {{pandas_version:3.x}} code to load this CSV correctly.
Header and first rows:
{{csv_sample}}
Problems I know about: {{problems:IDs with leading zeros, "N/A" and "-" meaning missing, numbers with commas, dates in day/month/year}}
Use read_csv arguments (dtype, na_values, thousands, parse_dates, date_format) instead of fixing things afterward where possible. For any date column that needs pd.to_datetime, use errors="coerce" and then print how many values became NaT, so nothing is lost silently.
4. Write a cleaning plan before cleaning
Here is a profile of my dataset (dtypes, null counts, value counts):
{{profile}}
Propose a cleaning plan as a numbered list. For each step: the column, the problem, the fix, and how many rows it affects. Flag any step that drops rows or changes values, and suggest what to do instead of dropping where possible. Don't write code yet. I'll approve the plan first.
5. Find duplicates and outliers
Write {{tool:pandas}} code that checks this dataset for duplicates and outliers.
Columns that should identify a row uniquely: {{key_columns:order_id}}
Numeric columns to check: {{numeric_columns}}
1. Count exact duplicate rows and duplicate keys separately, and show examples of each.
2. For each numeric column, flag values outside 1.5 times the IQR and values that are impossible (negative quantities, dates in the future).
3. Don't remove anything. Output a table of flagged rows with the reason, so I can decide.
6. Join two tables without losing or doubling rows
Bad joins are the most common silent error in analysis. In pandas, merge has a validate argument that checks the join keys are unique the way you expect (one to one, one to many, many to one), and indicator=True adds a _merge column showing where each row came from.
I need to join these two tables in pandas.
Left table ({{left_grain:one row per order}}):
{{left_columns}}
Right table ({{right_grain:one row per customer}}):
{{right_columns}}
Join key: {{key:customer_id}}
Write the merge with how="left", validate set to the relationship you expect, and indicator=True. Then print the row count before and after, and the count of each _merge value. Explain what it means if the row count goes up, and what to do about right_only or left_only rows.
How do you turn a business question into SQL or pandas?
7. Same answer in pandas and SQL
Writing it both ways and comparing results is a cheap correctness check.
Question: {{question:monthly revenue by product category for the last 12 months, with month-over-month change}}
Table schema:
{{schema}}
Write the answer twice: once in pandas and once in {{dialect:PostgreSQL}}. Make both produce the same columns in the same order. List the assumptions both rely on (time zone, how refunds count, what "last 12 months" means) and give me one query I can run to spot-check the result.
8. Cohort retention table
Build a monthly cohort retention table in {{tool:pandas}}.
Events table: {{columns:user_id, event_date, event_type}}
Cohort = month of a user's first {{first_event:signup}}.
Active = at least one {{active_event:purchase}} in the month.
Output: one row per cohort month, columns for month 0 through month {{months:12}}, values as the percentage of the cohort still active. Explain how you handle users with no active events and cohorts too young to have later months.
9. Fix or modernize pandas code
This pandas code {{problem:gives a warning and sometimes doesn't update the column}}.
{{code}}
I'm on pandas {{pandas_version:3.x}}. Rewrite it so it works on that version: no chained assignment, use .loc for updates, and don't rely on string columns being object dtype. Explain each change in one line. If any line behaves differently between pandas 2 and 3, point it out.
How do you choose and build the right chart?
10. Pick the chart for the message
I want to show {{message:that support tickets spike every Monday and that the spike is getting smaller}}.
Data: {{data_description}}
Audience: {{audience:executives reading on a phone}}
Suggest the best chart type and one alternative. For the best one: what goes on each axis, how to sort, which single thing to highlight, the title as a one-sentence takeaway, and what to leave out. Tell me which chart types would mislead here and why.
11. Write the chart code
Write {{library:matplotlib}} code for a {{chart:line chart}} from this DataFrame:
{{dataframe_info}}
Requirements: title that states the takeaway, labeled axes with units, readable tick labels, no chart junk, one highlight color for {{highlight:the current year}} and gray for everything else, and save it as a PNG at 2x resolution. Keep the code short and commented.
How do you sanity check an analysis before sharing it?
12. Check a result before it goes in a deck
This is the prompt that saves you from presenting a wrong number.
Here is a finding I'm about to share:
"{{finding:Customers who used feature X spend 40% more.}}"
How I got it:
{{method}}
Act as a skeptical reviewer. Check for: wrong denominators, selection bias, Simpson's paradox (does the effect reverse within segments?), time window choices that change the answer, small sample sizes, and correlation presented as cause. For each risk, give a quick test I can run on my data. Then rewrite the finding in a way that only claims what the data supports.
13. Sanity check an A/B test
Check this A/B test result before we ship.
Metric: {{metric:conversion rate}}
Control: {{control:10,000 users, 520 conversions}}
Variant: {{variant:10,000 users, 580 conversions}}
Test ran for: {{duration:14 days}}
1. Compute the difference, a 95% confidence interval and a p-value, showing the formula you used.
2. Check for a sample ratio mismatch.
3. List what would make this result untrustworthy (peeking, novelty effects, multiple metrics tested).
4. Give a plain-language verdict a product manager can act on.
14. Write the summary people will read
Turn these analysis results into a summary for {{audience:the leadership team}}.
Results:
{{results}}
Format: the answer in one sentence first, then three supporting points with the numbers, then caveats, then the recommended next step. Under 200 words. No jargon like "statistically significant" without saying what it means. Don't add any number that isn't in the results above.
Where does AI help most in data analysis, and where should you check it?
AI is fastest at the parts of analysis that are tedious but easy to verify: writing load and cleaning code, translating a question into a query, drafting chart code and turning results into plain language. You can rerun the code and see if it does what it claims.
It needs the most checking where errors are invisible:
| Task | Risk | How to check |
|---|---|---|
| Joins | Rows silently duplicated or dropped | Compare row counts before and after; use merge with validate and indicator |
| Date parsing | Day and month swapped, or values turned into NaT | Count NaT after parsing; check the min and max date |
| Aggregations | Wrong grain, so totals are double counted | Recompute one total by hand from the raw data |
| Statistics | Wrong test, or a significant result from many comparisons | Ask which test and why; count how many metrics you tested |
| Summaries | Numbers that aren't in your results | Ask the model to cite the source row or cell for every number |
A good rule: never put a number in front of other people that you haven't reproduced from code you can rerun.
Make your data prompts a skill
If you open every new dataset with the first-look prompt, turn it into a skill so Claude Code or Codex runs it on its own. Paste it into the SKILL.md generator. For work that ends in a spreadsheet, the Claude Excel skill builds .xlsx files with live formulas.
Kipt stores prompts like these as Markdown in a private GitHub repo you own. Blanks such as {{pandas_version:3.x}} stay fillable, tags keep analysis prompts apart from the rest, and ⌘K finds any of them.