Back to Blog
data analysispromptsAIChatGPT

Best Prompts for Data Analysis: Get Real Insights from AI on Your Data

July 4, 2026·16 min read·By PromptWright Team

Spreadsheets got bigger, dashboards got busier, and somewhere along the way "data analysis" turned into "staring at a wall of numbers and hoping a pattern jumps out." Modern AI models are genuinely good at the parts that slow humans down — summarizing, pivoting, spotting anomalies, writing the SQL or Python to transform a messy table — but only when you prompt them precisely. A vague "analyze this data" prompt gets you a vague summary. A structured prompt that assigns a role, defines the inputs, lists the exact outputs, and enforces a reasoning chain gets you analysis you can actually use.

This guide collects the best prompts for data analysis with models like ChatGPT, Claude, and Gemini. Each one is ready to paste in, adapt, and run. We cover data cleaning, exploratory analysis, statistical summaries, visualization, written insights, and code generation for analysis pipelines. By the end you will have a set of templates you can reuse on any dataset.

Why AI Is Useful for Data Analysis

Before the prompts, it is worth being precise about what AI does well and badly with data.

What AI models do well

  • Explaining a dataset in plain language. Describe the columns and get back a human-readable summary of what the data likely contains and how to approach it.
  • Writing transformation code. Pandas, SQL, R, and Excel formulas — AI reliably drafts correct transformation and aggregation code given a clear schema.
  • Generating hypotheses and questions. Point AI at a dataset description and it will surface questions worth investigating that you might not have thought to ask.
  • Drafting narrative insights. Turn a set of numbers into a written paragraph a stakeholder can read without opening a spreadsheet.
  • Catching anomalies and data quality issues. AI is good at noticing missing-value patterns, impossible values, and inconsistent formatting.

What AI models do badly (without help)

  • Exact arithmetic on raw numbers pasted into chat. Models are not calculators; large numerical tables pasted directly into a prompt will be summarized approximately, not computed exactly. For exact math, ask the model to write code (which you then run), not to do the math itself.
  • Reliable row counting. Models routinely miscount rows in pasted tables. Always use code, not the model's internal count, for anything that needs to be exact.
  • Preserving privacy-sensitive raw data. Pastin customer-level data into a hosted model is a compliance risk. Anonymize or summarize before prompting.

The single most important habit in AI-assisted data analysis is this: use the model to plan, explain, and write code; use the code (run yourself) to compute. Almost every prompt below reflects that split.

Foundational Data Analysis Prompt: Dataset Orientation

The first prompt to run on any new dataset or schema is an orientation prompt. This asks the model to describe what it is looking at and propose an analysis plan before any transformation begins.

Dataset orientation template

You are a senior data analyst. I will describe a dataset below. Do NOT
start computing. Instead:

1. Restate what each column represents in plain language, including a
   best guess at the data type and likely range.
2. Identify the likely grain of the table (one row = one what?).
3. List 5-7 analytical questions this data could answer well, ranked from
   most obvious to most interesting.
4. Flag any columns that look potentially dirty, redundant, or
   misleading (e.g. IDs that look like counts, dates stored as strings).
5. Propose a 3-step analysis plan to go from raw data to a one-page
   summary a non-technical executive could read.

Dataset description:
- Table name: {table_name}
- Columns: {column list with types, or a paste of the first 5 rows}
- Context: {where the data came from, what business question prompted it}

This prompt earns its keep on every new dataset. It surfaces assumptions, catches dirty columns early, and turns a shapeless "analyze this" request into a concrete, ranked plan.

Best Prompts for Data Cleaning

Cleaning is the unglamorous 70% of data analysis. AI can draft the cleaning code for you; it should not do the cleaning by eye.

Generate a cleaning script

You are a meticulous data engineer. Write a Python pandas cleaning script
for the dataset described below.

Requirements:
- Handle missing values column by column: impute numeric columns with
  the median, categorical columns with the string "Unknown", and flag any
  row imputed with a boolean column {column}_was_imputed.
- Standardize date columns to ISO 8601. Infer the source format per
  column and comment on each inference.
- Strip and title-case string columns except IDs and codes.
- Drop exact duplicate rows and report how many were dropped via print().
- Add a final assertion that the cleaned DataFrame has no nulls in any
  required column (list them) and that row count is within 5% of the input.

Schema:
{paste the schema or df.dtypes output}

First 5 rows for reference:
{paste first 5 rows}

Output only the Python code in a fenced block, plus a short comment at
the top explaining any non-obvious decisions.

Anomaly and data-quality scan

Review this dataset profile and list any data quality issues you can
infer, grouped by severity (critical / warning / info). For each issue,
state the column, the symptom, the likely cause, and a suggested fix.
Do not invent issues; if you are unsure, say so.

Dataset profile:
- Shape: {rows} × {cols}
- dtypes: {paste df.dtypes}
- Missing counts per column: {paste df.isna().sum()}
- Numeric describe: {paste df.describe()}
- Unique counts per column: {paste df.nunique()}
- First 10 rows:
{paste first 10 rows}

This profile-driven scan is one of the highest-value prompts in the toolkit. It catches type drift, impossible ranges, duplicate IDs, and constant columns faster than a manual review.

Best Prompts for Exploratory Data Analysis

Once the data is clean, exploratory analysis is about asking the data questions and seeing what the shape of the answers tells you.

EDA question generator

Given the dataset description below, generate 15 exploratory data
analysis questions grouped as:
- 5 distribution questions (e.g. "How is column X distributed?")
- 5 comparison questions (e.g. "How does X differ across category Y?")
- 5 relationship questions (e.g. "Is X associated with Z, controlling for W?")
For each question, also state which single chart type best answers it
and which pandas or seaborn one-liner would produce it.

Dataset description:
{paste orientation summary or schema}

Automated EDA script

Write a Python script that produces a single HTML EDA report for the
DataFrame `df` using pandas, ydata-profiling, matplotlib, and seaborn.
The report must include:
1. A header with dataset name, row count, and column count.
2. Per-column: dtype, missing %, unique count, and a small chart
   (histogram for numeric, bar for categorical).
3. A correlation heatmap for numeric columns with |r| > 0.3 highlighted.
4. A "top 5 surprising findings" text section at the end, generated by
   computing basic stats and formatting them as bullet points.
Do not include any narrative you did not actually compute. Output only
the Python code.

The instruction "do not include any narrative you did not actually compute" is doing real work here — it stops the model from inventing findings that the code does not produce.

Best Prompts for Summary Statistics and pivots

For exact aggregation, always ask the model to write code rather than compute in its head. These prompts produce ready-to-run aggregation snippets.

Pivot and aggregation prompt

Given this DataFrame schema, write pandas code to produce the following
pivot table:

Rows: {row column(s)}
Columns: {column column(s)}
Values: {value column}
Aggregation: {sum/mean/count/etc}
Filters: {any filters to apply first}

Requirements:
- Output a clean pivot with subtotals per row group and a grand total.
- Sort rows by the grand total descending.
- Round numeric output to 2 decimals.
- Print the final pivot and its shape at the end.

Schema:
{paste}

Period-over-period comparison

I have a time-indexed DataFrame with daily rows and a numeric column
{metric}. Write pandas code to compute and print:

1. Day-over-day, week-over-week, and month-over-month percent change.
2. A 7-day rolling average and a 28-day rolling average, both aligned to
   the original index.
3. The best and worst single day, week, and month on record, printed as
   a small table.
4. A boolean column {metric}_anomaly that is True when the value is more
   than 3 standard deviations from the rolling 28-day mean.

Use only pandas and numpy. Output only the code.

Best Prompts for Data Visualization

AI cannot render a chart for you, but it can write the code to produce a correct, well-styled one and, crucially, pick the right chart type for the question.

Chart selection + code prompt

For the analytical question below:
1. Recommend the single best chart type and explain why in one sentence.
2. List 2 alternative chart types that would also work and the trade-off
   of each.
3. Write Python code using matplotlib and seaborn to produce the
   recommended chart with a clear title, axis labels, a data source
   footnote, and a colorblind-safe palette.
4. Include a comment on what pattern in the chart would support or refute
   the question's hypothesis.

Question: {your analytical question}
Schema: {paste schema}
Sample rows: {paste 5 rows}

Dashboard layout prompt

I need a 4-panel dashboard for this dataset. Propose a layout
(2x2 grid) where each panel answers one question, and write the Python
code (matplotlib subplots) to render all four. Each panel must have its
own title, axis labels, and a one-line caption underneath summarizing
the takeaway. The four questions are:
1. {question 1}
2. {question 2}
3. {question 3}
4. {question 4}
Schema: {paste schema}

The "one-line caption underneath summarizing the takeaway" instruction is the key — it forces the model to commit to an interpretation per chart, which you can then sanity-check against the actual rendered output.

Best Prompts for Written Insights and Reports

The endpoint of most analysis is a written paragraph a stakeholder reads. This is where AI's natural-language strength pays off — but only if you give it the computed numbers to talk about, not a vague "summarize the data."

Insight-from-results prompt

You are a senior analyst writing for a non-technical executive. Below
are computed results from a recent analysis. Turn them into a 200-word
insight summary that:

- Opens with the single most important finding (the "so what"), not a
  data description.
- Uses plain language; no jargon, no column names, no internal codes.
- Includes at most 3 supporting numbers, each one humanized (e.g. "about
  one in four users" not "24.7%").
- Names the recommended next action based on the finding.
- Closes with one open question the data does not answer.

Computed results:
{paste the actual numbers, pivot table output, or chart captions}

Executive one-pager prompt

Combine the following computed findings into a one-page executive
summary structured as:

## Headline (single sentence, the punchline)
## What we found (3 bullet points, plain language)
## Why it matters (2-3 sentences on the business implication)
## Recommended action (1-2 sentences)
## Open questions (bullet list)

Use only the findings provided. Do not invent numbers. If a finding is
ambiguous, say so rather than papering over it.

Findings:
{paste computed results}

The "do not invent numbers" and "say so rather than papering over it" guardrails are essential — without them, models will confidently fabricate supporting metrics that look plausible and are wrong.

Best Prompts for Code Generation: Analysis Pipelines

Beyond one-off scripts, AI is excellent at scaffolding repeatable analysis pipelines. These prompts produce code you can drop into a notebook or a scheduled job.

Full notebook scaffold

Write a single Jupyter notebook (as a Python script with # %% cell
markers) that takes a CSV at path {path} and produces:

Cell 1: Load and display schema + first 5 rows.
Cell 2: Clean per the following rules: {list cleaning rules}.
Cell 3: EDA — distributions and a correlation heatmap.
Cell 4: The core analysis: {describe the question and required
   aggregations}.
Cell 5: Visualizations answering the question.
Cell 6: A markdown cell with the narrative insight, left as a template
   for a human to fill in based on the outputs above.

Each code cell must start with a one-line comment stating what it does.
Use only pandas, numpy, matplotlib, and seaborn. Assume the notebook
runs top to bottom with no hidden state.

SQL analysis prompt

Given this schema (DDL below), write a set of analytical SQL queries that
answer the following questions. Use CTEs for readability, alias every
column in the final SELECT, and add a one-line comment above each query
stating the question it answers.

Questions:
1. {question 1}
2. {question 2}
3. {question 3}

DDL:
{paste CREATE TABLE statements}

Assume PostgreSQL syntax.

A Worked End-to-End Example

To show how these fit together, here is a short end-to-end session analyzing a fictional subscription dataset. You would run each block as a separate prompt and feed the output forward.

Step 1 — Orientation. Paste the schema and first rows into the dataset orientation prompt above. The output tells you the table is one row per subscription, identifies a started_at timestamp column stored as a string, flags plan_id as a categorical with only four values, and proposes a plan: clean dates, compute monthly revenue, segment by plan.

Step 2 — Cleaning. Feed the orientation output into the cleaning-script prompt. You get back pandas code that parses started_at to datetime, imputes the 12 missing country values as "Unknown", and drops 3 duplicate rows. You run it; the cleaned frame is ready.

Step 3 — Core analysis. Use the period-over-period comparison prompt on the monthly_revenue metric. The code produces day-over-day and month-over-month change columns plus an anomaly flag. You run it and see a clear spike in March.

Step 3b — Visualize. The chart selection prompt recommends a line chart with a 7-day rolling average overlay; the generated code produces exactly that. The chart confirms the March spike and shows it is concentrated in the Pro plan.

Step 4 — Insight. Paste the computed numbers (March Pro-plan revenue, the rolling averages, the anomaly flag) into the insight-from-results prompt. The model returns a 150-word summary a non-technical executive can read in 30 seconds, naming the spike, the plan, and the recommended next step (investigate the March acquisition campaign).

The point of the walkthrough is that the model never does the arithmetic — you do, via the code it wrote — but the model does the parts humans are slow at: planning, explaining, and writing the bridge from numbers to narrative.

Tips for Better Data-Analysis Prompts

A few habits make every prompt in this guide sharper.

  • Paste schemas, not raw data, when possible. A df.dtypes output and the first 5 rows are almost always enough context and far safer than pasting the full table.
  • Always ask for code on exact computations. The model writes great pandas and SQL; it is unreliable at mental arithmetic on pasted tables.
  • Force the model to label its assumptions. "State any assumptions you made before the code block" surfaces the inferences that would otherwise silently shape the output.
  • Use chain-of-thought on reasoning prompts. For questions like "what could explain this pattern," prefix with "reason step by step about possible explanations before ranking them" — it dramatically improves the quality of the hypotheses.
  • Anonymize before prompting. Hash or drop PII columns before any prompt; a column named customer_id is fine, a column of email addresses is not.
  • Ask for the takeaway explicitly. A prompt that ends with "and in one sentence, state the takeaway" yields outputs that are immediately usable in a report.

Common Pitfalls in AI-Assisted Data Analysis

  • Trusting model-computed numbers. If a number matters, the model should have written code that produces it, and you should have run that code.
  • Letting the model invent metrics in narrative. The guardrail "use only the findings provided; do not invent numbers" is non-negotiable for insight prompts.
  • Skipping orientation. Jumping straight to analysis without an orientation pass is how analysts spend an hour computing something the data doesn't actually support.
  • Pastin the whole dataset. Large pastes blow the context window, leak sensitive data, and still produce approximate results. Send schemas and samples.
  • Treating AI output as finished analysis. AI drafts; humans verify. The model's pivot or chart code is a strong first draft, but you should sanity-check row counts, aggregation direction, and units before relying on it.
  • One mega-prompt. Splitting the analysis into the orientation → clean → analyze → visualize → insight sequence, each its own prompt, produces vastly better results than a single "analyze this data" mega-prompt.

Putting It All Together

AI does not replace data analysis — it replaces the slow, mechanical, boilerplate-generating parts of it. Used well, with the prompts in this guide, a model will orient you to a new dataset in seconds, draft a cleaning script you would have written by hand over an hour, pick the right chart type, and turn your computed numbers into a tight executive summary. Used badly — by pasting raw tables and asking for vague summaries — it will confidently produce approximation layered on approximation. The difference is entirely in the prompt.

The workflow that consistently works is: describe the schema clearly, ask for code, run the code yourself, and feed the computed results back into a narrative prompt that is forbidden from inventing numbers. Do that, and AI becomes a genuine multiplier on your analysis throughput.

If you want a managed environment to build, version, and evaluate prompts like these — so your team shares a library of tested data-analysis prompts instead of reinventing them in every chat window — sign up for free at promptwright.net/signup and turn your best analysis prompts into reusable, reviewable assets.

Enjoyed This Article?

Get more prompt engineering tips delivered weekly. Free, no spam.

Join 500+ prompt engineers. Unsubscribe anytime.

Ready to build better prompts?

Try PromptWright free — structured prompt editor with multi-model testing.

Get Started Free →