Data Analysis in Three Steps: Clean, Aggregate, Interpret Prompt Chain
Most data analysis prompts fail not because the model is weak, but because cleaning, aggregation, and interpretation are crammed into one sentence. A more reliable approach is a three-step prompt chain: each step has one clear goal, and each step's output feeds the next. DeepSeek's V series handles structured tasks like cleaning well; for steps involving statistical definitions or attribution reasoning, turn on the R series' deep thinking mode. No need to trigger it for simple steps—it saves cost and responds faster.
Step 1: Cleaning—Let the Coding Strengths Handle the Dirty Work
The key to cleaning is not "please clean this data," but spelling out the data issues, the handling rules, and the output format. DeepSeek is strong at code, so asking it to produce runnable Python is more reliable than a verbal description. Use a template like this:
Task: clean the following sales data. Sample data: date,city,sales 2024-01-01,Beijing,1200 2024/01/02,Shanghai,missing 2024-01-03,beijing,980 Requirements: 1. Normalize dates to YYYY-MM-DD 2. Normalize city names to standard Chinese forms 3. Rule for missing sales: drop the row, and report how many were dropped 4. Output: runnable Python (pandas) code with a one-line usage note
Key point: list the rules item by item and lock the output format to code. Deep thinking mode adds little here—turning it off is the better deal.
Step 2: Aggregation—Pin Down the Definitions, Leave No Room for Guessing
The most common failure in aggregation is vague definitions: year-over-year or month-over-month? Deduplicate on which key? For this step, enable deep thinking and ask the model to restate the definitions before computing—error rates drop noticeably. Template:
Task: aggregate the cleaned data. Data: (paste the cleaned output or file content) Aggregation requirements (definitions are fixed; do not change them): 1. Sum monthly sales by city, output as a table 2. Compute month-over-month growth per city, base period = previous calendar month 3. Rows with zero sales are excluded from growth calculations and listed separately Execution: write Python code to compute, then present the result table. Before computing, restate your understanding of each definition and confirm no ambiguity.
The "restate definitions before computing" constraint works especially well with reasoning models—it surfaces conflicting definitions before any math happens.
Step 3: Interpretation—Bring in Reasoning, but Demand Evidence
Interpretation is the only step that genuinely needs deep thinking. The usual failure mode is a pile of "possibly" and "perhaps" that says nothing. The fix is forcing evidence binding: every conclusion must point to a specific number in the data, and the model must separate "data-backed judgments" from "assumptions needing more data." Template:
Task: interpret the following results; do not repeat the numbers. Data: (paste the Step 2 result table) Business context: offline retail sales for H1 2024; East China is the priority region. Requirements: 1. Every conclusion must cite a specific value from the data as evidence 2. Label each item as either [Data-backed judgment] or [Assumption needing more information] 3. Propose at least 2 follow-up analyses that could verify your hypotheses 4. Say "uncertain" when uncertain—do not invent causes
Two Practical Details for Running the Chain
First, context management: the three steps can run sequentially in one conversation. DeepSeek handles Chinese well, so you can simply say "continue to Step 2, using the DataFrame from the previous step." For large datasets, prefer file upload over pasting long text. Second, mode switching: keep thinking off for cleaning, on for aggregation and interpretation—this is the highest-value habit in the whole chain. For the exact toggle details, refer to the current official documentation.
One-Shot Version: Merged Chain for Small Tasks
If the dataset is small and you just want a quick look, skip the three steps and use a merged prompt:
Here is raw sales data. Complete the following in order: 1) Clean: normalize dates, standardize city names, drop missing values and report the count; 2) Aggregate: sum sales by city and compute month-over-month growth; 3) Interpret: give 2 conclusions backed by data evidence and 1 hypothesis to verify. Separate each step with a divider. In the interpretation section, every conclusion must cite specific numbers. Data: (paste data)
The core of this chain is not the templates themselves but three habits: one goal per step, definitions pinned down, and conclusions tied to evidence. Plug your own spreadsheet into any of the templates above and run it once—you'll see the difference immediately.
大模型网摘