Working with data has always been split between exploration and execution. Exploration — which features matter, what this column is really storing, how to show a pattern — is the part that needs human judgment. Execution is where analysts burn 40% of their time: writing groupby statements, fixing datetime formats, adjusting matplotlib parameters, remembering whether it is fig.tight_layout() or plt.tight_layout().
Prompt-based data science collapses execution time toward zero. In 2026, a well-structured prompt with a DataFrame schema and explicit output requirements produces working pandas code in a single pass. The catch: prompts designed for generic coding tasks fail in data work because they lack context. Nobody can write the right aggregation without knowing your columns, data types, and null patterns.
Below is a collection of prompts I actually use — not the toy ones from demo videos. Each includes the reasoning behind the structure and a realistic usage example. Steal them, adapt them to your schemas, and build your own library.
Why Data Science Prompts Are Different
Generic code prompts ask for a function. Data science prompts ask for a workflow.
Your DataFrame is context. An LLM cannot guess column names, dtypes, or null ratios — provide them. Data work is iterative: the first answer is a starting point, not a deliverable. Build prompts that output intermediate validation. There is no single right answer: a "sort and filter" prompt is trivial, but a "decide whether to remove these 300 outliers" prompt requires a plan and explicit trade-offs.
| Generic coding prompt | Data science prompt |
|---|---|
| "Write a function to sort a list" | "Sort 120K rows by revenue, keep top 5% flagged for review" |
| "Fix this bug in my loop" | "Find why mean of column A is NaN for group X, show offending rows" |
| "Chart this data" | "Chart sales by cohort, annotate the churn inflection point after week 6" |
The difference is context. The prompts below all enforce a context-first structure.
Pandas Prompts: Data Wrangling and Cleaning
1. The Full-Cleaning Prompt
The most used prompt in my toolbox. It forces the model to plan before touching code and prove that nothing was silently lost.
Prompt template:
You are a senior pandas engineer. I have a DataFrame with {n_rows} rows and columns: [{columns with dtypes}]. Known issues: {missing values, mixed date formats, duplicate rows, inconsistent categories}.
Step 1: Write a cleaning plan in priority order, with expected row impact for each step.
Step 2: Implement the plan as pandas code. Rules: never use dropna() without an explicit subset; record shape before and after every step; validate dtypes with df.info(); assert that key columns have zero NAs.
Step 3: Report initial shape, final shape, and a table of what was removed and why.
Why it works: the plan-first structure forces reasoning about consequences before code generation. The "record shape after every step" rule gives you an audit trail.
Real usage on a customer dataset: 48,203 rows with customer_id, signup_date, last_active, plan, monthly_revenue. Mixed ISO and dd/mm/yyyy dates, negative revenue values, inconsistent plan categories ("pro" and "Pro"). The output was a five-step plan — normalize dates, map categories, flag negative revenue, compute lifetime, deduplicate. Final result: 47,994 rows, 3 duplicate IDs removed, 21 outliers flagged instead of dropped.
2. The Broken Column Fixer
A tiny, targeted prompt for columns that look like they went through a blender — but only if you include sample values.
Here are 15 sample values from column "amount": ['1,234.56', '$1,234.56', '1234.56', '1.234,56', 'N/A', '1234']. This column contains order amounts. Normalize it to float64. Handle thousands separators, currency symbols, and European decimal commas. Show the pandas strategy, then give the count of values that remained unparseable.
Sample values matter more than the column name. With five examples, the model infers the exact format zoo in your data.
3. Performance Groupby
Large-data aggregations are a classic pandas struggle. This prompt deploys the right tools.
I have a DataFrame with 2.3M rows: user_id, order_id, order_date, amount, region. I need per-user aggregates: order count, total amount, first and last order date, average days between orders. Constraints: no iterrows or apply loops. Use named agg on grouped objects. For average days between orders, suggest a vectorized approach plus a fallback. Explain the runtime difference between agg() and pivot_table() at this volume.
The result used df.groupby("user_id").agg(...) with named aggregations and a shift-diff trick for the interval metric — no loops.
Data Analysis Prompts: EDA, Statistics, Hypotheses
4. EDA Report Generator
Most EDA prompts produce a describe() call and two histograms. The fix is context plus a required priority order.
Generate an EDA plan for a subscription churn dataset. Columns: {list}. Target: {name}. For each column, specify: chart type, statistical metric to inspect, and which patterns are red flags. Skip basic mean/median checks. Output a prioritized checklist: missing-data patterns first, then univariate distributions, then bivariate relationships with the target, then multicollinearity. For the last step, specify the correlation method suited to the data types.
Demanding "first X, then Y, then Z" stops generic boilerplate and forces a real analytic sequence.
5. Hypothesis Testing
Hypothesis testing is 80% assumption verification and 20% test execution. The prompt reflects that split.
I want to test whether promotion A vs control changes weekly retention. Data: two groups, sizes {x} and {y}, retention is {binary or continuous}. Propose the test, check assumptions with code (normality, variance equality, sample size), and if assumptions fail, recommend an alternative. Output: hypotheses, chosen test with reasoning, assumption-check code, final test code, and one business-level sentence explaining the result.
The assumption-check requirement is critical. Without it, models default to a t-test on non-normal skewed retention data.
6. Feature Engineering Brainstorm
I have columns: {list} and target: {target}. Dataset size: {n}. Suggest 8 candidate features. For each: name, pandas code, mathematical definition, expected value for the model, and leakage risk. Prioritize by value/effort ratio and mark the top 3 to implement first.
The code requirement keeps suggestions actionable. The leakage-risk column forces the model to think about temporal or target-driven leaks.
Visualization Prompts: Matplotlib and Seaborn
7. Publication-Ready Matplotlib
Chart formatting consumes more time than chart logic. This prompt compresses both into one shot.
Create a publication-ready chart. Data: {paste df head}. Plot: daily revenue time series, highlighting the launch campaign week. Use the Matplotlib object-oriented API — no pyplot state machine. Set figsize, dpi=150, explicit axis labels with units, title, legend outside, subtle gridlines. Annotate the campaign week with a shaded vertical span and a text box. Use a colorblind-safe palette.
Typical outcome: an annotated, well-spaced chart in one pass plus one small fix.
8. Seaborn Comparison Chart
Seaborn makes categorical charts pretty — but choosing the right plot type is a decision the model should justify.
Compare {metric} by {category} using Seaborn. Context: {n, distribution shape, outliers}. Choose between boxplot, violinplot, stripplot, and boxenplot. Justify the choice based on sample size and distribution. Implement with consistent hue mapping, annotate medians, remove top/right spines, and set a colormap appropriate for the number of categories. Handle overlapping points with dodge and alpha.
The justification requirement often produces the better choice: boxenplot for large datasets with heavy tails, stripplot for small samples.
9. The "Make It Not Ugly" Refactor
The best prompt for a working chart that looks like it is from 2012.
Here is my current chart code: {paste}. Problems: default styling, overlapping x-tick labels, legend inside the plot, poor colors. Refactor: use a modern style context, rotate tick labels, move the legend outside, apply a cohesive colormap, add annotations that guide the eye to the main insight, increase print contrast. Show the full revised code.
Highest value-to-effort prompt in the list: acceptable chart to presentation-grade in one interaction.
Prompt Selection Guide
| Prompt | Use case | Time saved | Level |
|---|---|---|---|
| Full-Cleaning Prompt | Any new dataset, ETL | 15-25 min | Any |
| Broken Column Fixer | Malformed columns | 5-10 min | Any |
| Performance Groupby | Large DataFrames | 10-20 min | Intermediate |
| EDA Report Generator | Initial exploration | 20-30 min | Any |
| Hypothesis Testing | A/B tests, validation | 10-20 min | Intermediate |
| Feature Engineering | Model prep | 15-25 min | Intermediate+ |
| Publication-Ready Matplotlib | Reports, dashboards | 5-10 min | Any |
| Seaborn Comparison | Categorical analysis | 5-10 min | Any |
| Not-Ugly Refactor | Final deliverables | 10 min | Any |
Best Practices for Data Science Prompts
- Paste the schema, always. Column names, dtypes, row counts, and sample values. This is the single biggest factor between generic and useful answers.
- Insist on validation. Ask for shape comparisons, NA counts, and assert statements. This forces the model to check its work and gives you an audit trail.
- One task per prompt. "Clean, plot, then run a t-test" produces a shallow version of all three. Split them.
- Include a sample of the actual data. Five rows of real or anonymized data prevent hallucinated column names and formats.
- Treat answers as drafts. The first output is the starting point. Follow-up prompts like "check assumption X and adjust" build the final result.
- Build a prompt library. Keep versions of these templates where only the context block changes. Over time, this becomes a reusable data engineering toolkit.
Common Pitfalls and How to Avoid Them
| Pitfall | Why it happens | Fix |
|---|---|---|
| Hallucinated column names | No schema provided | Include dtypes and sample values |
| Silent row drops | Generic dropna() calls | Demand shape before/after every step |
| Wrong statistical test | No assumption checking | Require assumption-check code |
| Ugly default charts | No style requirements | Specify style, dpi, palette, annotations |
| Leaked features | No target-awareness | Ask about leakage risk explicitly |
Conclusion
Prompt-driven data science does not replace your judgment. It makes the execution layer nearly free so you can spend attention where it matters: understanding the problem, validating results, and communicating the story.
Start with the pandas cleaning prompt on a real dataset today. Add the EDA generator tomorrow. Then the visualization refactor. Within a week, you will have a personal prompt library that saves more time than most tools in your stack.
The prompts are templates — make them yours. Adjust the context block, deepen the validation requirements, and share your variants.
Want more hands-on data science material? Subscribe to the Asibiont blog — we publish practical guides on LLM-assisted data work, Pandas, and visualization every week.
Comments