Prompt Patterns for Data Analysis
Structure prompts so an AI assistant helps you explore and summarize data accurately instead of inventing plausible-sounding numbers.
The core risk: invented numbers
A language model does not calculate the way a spreadsheet or a script does by default — when asked directly about numeric data in a prompt, it can produce plausible-sounding but incorrect figures, especially with larger datasets or multi-step arithmetic. Treat any number it reports back about your data as a claim to verify, not a computed fact, unless it is explicitly using a code-execution or tool-calling feature that runs real calculations.
Prefer code execution over mental math
Where the tool supports it, explicitly ask the assistant to write and run code (Python, SQL) against your actual data rather than reasoning about the numbers in plain text. A written and executed calculation is verifiable and reproducible; a purely narrated calculation is not, no matter how detailed the explanation sounds.
Data: attached CSV, 3 columns (date, region, revenue), 2,400 rows.
Question: Which region had the largest month-over-month revenue drop
in the last quarter, and by how much?
Rules: only use numbers present in the data; if a month is missing
for a region, say so instead of estimating it.
Return: the answer, the calculation shown, and any data gaps found.State what counts as missing or invalid data
Real datasets have gaps, duplicates, and inconsistent formatting. Tell the assistant explicitly how to handle missing values (flag them, do not estimate them) and what to do if a question cannot be answered from the given data. Without this instruction, a model will often fill a gap with a reasonable-sounding estimate and present it with the same confidence as a real data point.
Ask for the method, not just the conclusion
Requesting that the assistant show its calculation, the specific rows or filters used, and any assumptions made turns an unverifiable one-line answer into something you can actually check. This is especially important for any analysis that will inform a real decision, where an unexamined wrong number can be costly.
Use it for exploration, verify before deciding
AI assistance is genuinely useful for generating hypotheses, suggesting which columns might be worth investigating, or drafting exploratory SQL and plotting code quickly. It is a poor substitute for your own verification on any number that will appear in a report, a decision, or a stakeholder communication — always reproduce the key result independently before relying on it.
Practical exercise
Take a small dataset you have access to and ask an assistant a question with a clear numeric answer, first without asking it to run code, then again explicitly requesting it write and execute code against the data. Compare the two answers against the true value you compute yourself, and note which method was accurate.
Sources and further reading
These primary or specialist references informed the concepts in this guide. Product details can change, so verify current documentation before implementation.