12 Prompts for Data Science: Pandas, Visualization & Analysis
Data science rarely starts with a clean dataset. Most real projects begin with a messy CSV, inconsistent column names and unclear business goals. Large language models can dramatically speed up exploratory data analysis (EDA), especially when you use clear prompts that describe your data, your desired output and your constraints. This collection gives you 12 data science prompts that cover the entire EDA workflow: loading data, cleaning it, computing aggregations, detecting outliers, visualizing distributions and communicating results.
Each prompt includes a concrete scenario and a short pandas, matplotlib or seaborn example. Treat these prompts as starting points: adapt the column names to your data, and always validate the output.
How to Use These Prompts Effectively
In our experience, prompt quality matters more than model quality. A good data science prompt contains:
- A clear role: "Act as a data analyst..."
- The dataset context: file name, columns, units
- The expected output: code, summary, table, or chart
- A constraint: "Do not modify the original DataFrame" or "Handle missing values"
This is the same level of detail you would give to a junior colleague. Vague prompts produce vague output.
12 Ready-to-Use Data Science Prompts
1. Audit Your DataFrame
Scenario: You just received sales.csv and want to know if it is usable.
Prompt: Act as a data analyst. Load sales.csv with pandas. Print the shape, data types, missing values and descriptive statistics. List three data-quality issues.
Code:
import pandas as pd
df = pd.read_csv('sales.csv')
print(df.shape)
print(df.dtypes)
print(df.isna().sum())
print(df.describe(include='all'))
Why this works: It forces a systematic EDA and treats the response as a deliverable, not just code.
2. Normalize Column Names and Types
Scenario: Columns are named 'Customer ID', 'Order Date'; dates are strings.
Prompt: Normalize column names to snake_case, convert Order Date to datetime and set it as the index. Show the before and after structure.
Code:
df.columns = [c.strip().lower().replace(' ', '_') for c in df.columns]
df['order_date'] = pd.to_datetime(df['order_date'])
df = df.set_index('order_date')
Goal: Consistent naming makes later prompts reuse easier.
3. Choose a Missing-Value Strategy
Scenario: age, income and city have different amounts of nulls.
Prompt: For the columns age, income and city, propose a strategy: drop, median imputation or mode imputation. Justify each choice based on missingness percentage and business context.
Code:
df['age'].fillna(df['age'].median(), inplace=True)
A good answer will discuss bias and whether missingness is informative.
4. Group By, Aggregate, and Sort
Scenario: Regional performance report.
Prompt: Group orders by region. Compute total revenue, average order value and order count. Sort the result by total revenue descending.
Code:
result = df.groupby('region').agg(
total_revenue=('revenue', 'sum'),
avg_order_value=('revenue', 'mean'),
order_count=('order_id', 'count')
).sort_values('total_revenue', ascending=False)
This pattern covers 80% of business reporting tasks.
5. Merge Tables with a Key
Scenario: users and purchases share user_id, but there are users with no orders.
Prompt: Merge users and purchases on user_id using an inner join. Explain how many users were dropped and why. Compare with a left join.
Code:
merged = users.merge(purchases, on='user_id', how='inner')
dropped = len(users) - merged['user_id'].nunique()
The distinction between inner and left join is a common interview question, so worth testing.
6. Build a Pivot Table
Scenario: Revenue by weekday and marketing channel.
Prompt: Create a pivot table with weekday as rows, channel as columns and revenue as values. Set margins=True and show how to reset the MultiIndex.
Code:
pivot = df.pivot_table(index='weekday', columns='channel',
values='revenue', aggfunc='sum',
margins=True)
pivot = pivot.reset_index()
Pivot tables help compare segments without writing long groupby chains.
7. Flag Outliers with the IQR Rule
Scenario: Several revenue values seem unrealistically low or high.
Prompt: Detect outliers in revenue using the IQR method. Return a DataFrame with the outliers and state how many rows would be removed.
Code:
Q1, Q3 = df['revenue'].quantile([0.25, 0.75])
IQR = Q3 - Q1
outliers = df[(df['revenue'] < Q1 - 1.5*IQR) |
(df['revenue'] > Q3 + 1.5*IQR)]
This is a quick sanity check, not a substitute for statistical outlier tests.
8. Resample a Time Series
Scenario: Daily sales need to be summarized monthly.
Prompt: Resample daily sales to monthly totals and plot the result. Explain resample('ME') (calendar month end) and how to handle timezone-aware timestamps.
Code:
monthly = df['revenue'].resample('ME').sum()
monthly.plot()
Time series prompts should always specify the rule: 'D', 'W', 'ME', or 'QE'.
9. Make a Publication-Ready Bar Chart
Scenario: A slide deck needs one simple chart without default matplotlib styling.
Prompt: Create a professional bar chart of sales by category with a title, axis labels, grid and value labels on top of each bar.
Code:
ax = df.groupby('category')['revenue'].sum().plot(kind='bar')
ax.bar_label(ax.containers[0])
Check the official Matplotlib docs for style galleries and accessible color palettes.
10. Compare Distributions with Seaborn
Scenario: Compare revenue across customer segments.
Prompt: Use seaborn histplot with kde=True and hue='segment'. Add dashed lines for each segment's median and interpret skewness.
Code:
import seaborn as sns
sns.histplot(data=df, x='revenue', hue='segment', kde=True)
Seaborn's defaults handle much of the formatting you would otherwise spend hours tuning.
11. Visualize a Correlation Matrix
Scenario: Feature selection before modeling.
Prompt: Print the correlation matrix for numeric columns and plot a heatmap. Highlight pairs with an absolute correlation above 0.7 and suggest what to do with multicollinearity.
Code:
corr = df.select_dtypes(include='number').corr()
sns.heatmap(corr, annot=True, cmap='coolwarm')
Use domain knowledge before dropping correlated features.
12. Turn Results into a Stakeholder Story
Scenario: You have outputs from prompts 1–11 and need to present.
Prompt: Based on the provided outputs, write a 200-word summary for a non-technical audience: three key insights and three actionable recommendations. Mention each chart by name.
No code needed, but this prompt separates analysts from great communicators.
Key Sources
For background and syntax, always rely on the official docs:
- Pandas: pandas.pydata.org/docs
- Matplotlib: matplotlib.org/stable
- Seaborn: seaborn.pydata.org
- Tidy Data paper by Hadley Wickham for principles behind cleaning: available at vita.had.co.nz/papers/tidy-data.pdf
Final Thoughts
A prompt is a contract between you and the model. The more data context you give, the more relevant the generated code and commentary. Start with prompt 1 on your own dataset, then work through the list. You will quickly build a repeatable EDA pipeline that you can reuse for every new project. The goal is not to automate judgment, but to reduce the time between loading a file and understanding it.
Comments