All posts
prompt-engineeringdata-analysisllm

Prompt Templates for Data Analysis: Ready-to-Use Templates

Copy-paste prompt templates for data analysis with real examples, plus what to change for your own use case.

SR

Suhail Roushan

August 6, 2026

·
6 min read
·
0 views

Every data analyst loses hours to vague AI responses that produce generic insights instead of actionable findings. These prompt templates for data analysis force LLMs to follow your exact workflow, output format, and reasoning constraints — turning Claude, GPT-4, Gemini, or DeepSeek from a chatty assistant into a structured analysis tool.

Why Generic Prompts Fail Here

The default "analyze this data" prompt fails because LLMs optimize for plausible-sounding answers, not correct ones. They'll invent correlations, skip null-value handling, and present averages without context. I've seen Claude confidently report a 40% conversion increase that was actually a data-entry artifact.

Generic prompts also lack output structure. You get a wall of prose when you need a decision-ready summary. The failure mode is consistent: the model doesn't know your data quality issues, your business context, or your required output format. These templates solve that by embedding constraints directly into the prompt.

Template 1: The Exploratory Data Audit

Use this when you have a raw CSV or SQL export and need to understand what you're working with before any analysis.

You are a senior data analyst. I will provide a dataset. Perform a structured exploratory audit.

DATASET: [paste sample of 20-50 rows, or describe schema with column names and types]

TASKS:
1. List each column, its data type, and the percentage of missing values.
2. Identify any obvious data quality issues (duplicates, outliers beyond 3 standard deviations, inconsistent formats).
3. For each numeric column, report: min, max, mean, median, and standard deviation.
4. For each categorical column, report: unique value count and top 5 values with frequencies.

OUTPUT FORMAT:
Use a markdown table for each section. Add a "RED FLAGS" section at the end listing only issues that would materially affect downstream analysis. Do not provide recommendations — just observations.

CONSTRAINTS:
- If the data is insufficient to complete a task, say "INSUFFICIENT DATA" and explain what's missing.
- Do not fabricate values. If you cannot compute something, say so.

Placeholders explained: [paste sample...] — give 20-50 rows; enough for pattern detection without hitting token limits. The "RED FLAGS" section forces prioritization — you don't want 40 issues, you want the 4 that matter.

Template 2: The Hypothesis Tester

This one's for when you have a specific question — "did the new pricing page increase signups?" — and need statistical rigor, not vibes.

You are a statistician. I will give you a hypothesis and data. Test it properly.

HYPOTHESIS: [state your specific claim, e.g., "Users who saw the new checkout flow complete purchases 15% more often"]

DATA:
[provide two groups: control and treatment, with sample sizes and success counts, OR paste raw data]

TASKS:
1. State the null and alternative hypotheses in plain language.
2. Check assumptions: are samples independent? Is the sample size sufficient for a z-test or t-test? If not, say so.
3. Run the appropriate test (chi-square for proportions, t-test for means). Show your work — include the test statistic and p-value.
4. Report the effect size (Cohen's h for proportions, Cohen's d for means).
5. Give a verdict: REJECT or FAIL TO REJECT the null hypothesis, with a confidence level.

OUTPUT FORMAT:
Use numbered sections matching the tasks above. End with a single "BOTTOM LINE" sentence a non-technical stakeholder could understand.

CONSTRAINTS:
- If the data doesn't meet test assumptions, recommend an alternative test — do not proceed with an invalid test.
- Report p-values to 4 decimal places.
- Do not use Bayesian methods unless I explicitly request them.

This template works because it demands the model show its work. LLMs are surprisingly good at calculating chi-square statistics correctly when forced to output intermediate steps — the reasoning chain keeps them honest.

Template 3: The Time-Series Anomaly Hunter

Harder scenario: you have daily metrics over months and need to find why a spike or dip happened, not just that it happened.

You are a time-series analyst. I will provide a sequence of daily metrics. Find and explain anomalies.

DATA:
[provide date-value pairs, e.g., "2024-01-01: 342, 2024-01-02: 351, ..." — at least 60 data points]

TASKS:
1. Detect anomalies using a moving average (7-day window) plus 2 standard deviation bands. List every point outside the bands.
2. For each anomaly, classify it: SEASONAL (expected pattern), LEVEL SHIFT (sustained change), or TRANSIENT (one-off spike/dip).
3. For the top 3 anomalies by deviation magnitude, propose plausible causes. Base this only on the data pattern — do not invent external events.
4. Forecast the next 7 days using a simple exponential smoothing model. Show the formula you used.

OUTPUT FORMAT:
- Section 1: table with date, value, expected value, deviation, classification.
- Section 2: bullet points for each top anomaly with reasoning.
- Section 3: table of forecasted values with 80% confidence intervals.

CONSTRAINTS:
- If fewer than 60 data points are provided, state that anomaly detection will be unreliable and proceed anyway.
- For classification, use the definitions I gave — do not redefine them.
- If a point is both seasonal and transient, classify it as TRANSIENT.

The key here is the classification system. Most LLMs will just say "there's a spike on March 3rd" — this template forces them to differentiate between a holiday dip (seasonal) and a broken tracking pixel (transient). That distinction is what actually helps you debug.

How to Adapt These for Your Own Codebase

First, replace the placeholder data with actual schema information from your database. If you're using Postgres, copy the \d table_name output. If you're working with pandas, paste df.dtypes and df.head(20).to_string().

Second, add your domain's vocabulary. If you're in e-commerce, tell the model what "cart abandonment" means in your context. If you're in SaaS, define what constitutes an "active user." LLMs have generic definitions — yours are probably different.

Third, tighten the constraints based on your tolerance for hallucination. I've found that adding "If you are unsure, output UNKNOWN rather than guessing" dramatically reduces fabricated numbers. You can also add a final validation step: "Re-read your output and flag any claim not directly supported by the data provided."

Do These Prompts Work With Any LLM?

Yes, but with caveats. Claude 3.5 Sonnet and GPT-4 Turbo handle the structured output format best — they follow multi-part instructions reliably. Gemini 1.5 Pro is comparable but sometimes truncates long tables. DeepSeek V3 is faster but occasionally skips the "show your work" step, so you may need to add "explain each calculation" explicitly.

For the time-series template, I've noticed Claude is strongest at anomaly classification while GPT-4 produces cleaner forecasts. The statistical test template works well on all four, but Gemini sometimes defaults to Bayesian language despite the constraint — you'll need to rephrase if that happens. Test each template with a small dataset you know the answer to before trusting any model with real analysis.

The single adjustment that improves these prompts the most is adding one sentence at the end: "Before answering, restate the key question in your own words." This forces the model to confirm it understood your intent, catching misalignment before it wastes your time with irrelevant output.

Related posts

Written by Suhail Roushan — Full-stack developer. More posts on AI, Next.js, and building products at suhailroushan.com/blog.

Get in touch