15 Data Science Prompts for Analysis, Visualization, and Pandas

15 Data Science Prompts for Analysis, Visualization, and Pandas

Data science is more than just running code — it's about asking the right questions. Every day, practitioners across industries use natural language prompts to accelerate their workflow, from quick data cleaning to generating publication-ready plots. This article is a battle-tested collection of 15 prompts you can actually use with AI assistants (like ChatGPT, Claude, or Copilot) to supercharge your data analysis, pandas wrangling, and visualization tasks.

Each prompt comes with a concrete usage context, a typical output, and tips to tweak it for your own data. No fluff — just practical, working examples.


Why Use Prompts in Data Science?

Before diving into the list, let's clarify the value. A well-crafted prompt acts as a mini-specification for your AI assistant. Instead of describing a problem abstractly, you give it a precise instruction, often with sample data, expected output format, and constraints. This turns a generic AI into a focused data science tool.

For instance, instead of asking "How do I clean this dataset?" you can say:

"Given a pandas DataFrame with columns ['date', 'price', 'volume'], write code to convert 'date' to datetime, drop rows with missing 'price', and add a column 'log_return' = log(price / price.shift(1))."

The difference is speed and precision. The following prompts are designed to be copied, pasted, and adapted.


Prompts for Pandas Data Wrangling

1. Quick Data Profile

Prompt:

I have a pandas DataFrame called 'df' with columns: ['user_id', 'signup_date', 'plan_type', 'monthly_revenue', 'churned'].
Write a function that prints:
- shape
- column dtypes
- missing values count per column
- basic descriptive stats for numeric columns
- unique values count for categorical columns

Use case: First look at any new dataset. Run this as a notebook cell to get an instant overview.

Example output:

Shape: (15000, 5)
Missing values:
  user_id: 0
  signup_date: 12
  plan_type: 0
  monthly_revenue: 45
  churned: 0
Numeric stats for monthly_revenue:
  count: 14955.0, mean: 49.99, std: 25.50, min: 0.0, 25%: 29.99, 50%: 49.99, 75%: 69.99, max: 199.99

Tip: Replace column names with your own. Add df.head().to_dict() to the prompt to let the AI see actual data.


2. Fill Missing Values Intelligently

Prompt:

Given a pandas DataFrame 'df' with column 'age' that has 15% missing values, and column 'income' with 8% missing values.
Write code to:
- Fill 'age' missing with the median of the same age group (buckets: 18-25, 26-35, 36-50, 50+)
- Fill 'income' missing with the mean income of the same education level (column 'education_level')
- Verify no missing remain

Use case: When you need contextual imputation, not just global mean/median.


3. Pivot Table Generator

Prompt:

From a DataFrame 'sales' with columns: ['date', 'region', 'product', 'sales_amount', 'quantity'],
create a pivot table showing total sales_amount by region (rows) and product (columns).
Also add a row for totals and a column for grand total.

Use case: Instant summary for reporting.


4. Time Series Resampling

Prompt:

I have a DataFrame 'df' with a datetime index (daily frequency) and column 'value'.
Write code to:
- Resample to weekly frequency (ending Sunday)
- Compute sum for each week
- Compute week-over-week percentage change
- Drop rows where previous week was zero

Use case: Financial or web traffic data aggregation.


5. Grouped Feature Engineering

Prompt:

For a DataFrame 'users' with columns ['user_id', 'purchase_date', 'amount'],
create features per user:
- total_spend
- average_order_value
- days_since_last_purchase (from today)
- purchase_frequency (number of purchases per month)
Return a new DataFrame with one row per user.

Use case: Building customer-level features for a churn or CLV model.


Prompts for Data Visualization (Matplotlib & Seaborn)

6. Publication-Ready Distribution Plot

Prompt:

Using seaborn, create a figure with two subplots side by side:
- Left: histogram of 'price' column with KDE overlay, 50 bins, color='#2E86AB'
- Right: boxplot of 'price' grouped by 'category' column, rotated x-labels
Set figure size to (12,5), add grid, and title 'Price Distribution Analysis'.
Save as high-res PNG (300 dpi).

Use case: Quick EDA for a numeric column.


7. Correlation Heatmap with Annotations

Prompt:

From a DataFrame 'df', select all numeric columns and compute the correlation matrix.
Plot a heatmap using seaborn with:
- Annotations (2 decimal places)
- Color palette: 'coolwarm'
- Mask the upper triangle
- Figure size (10,8)
- Title: 'Feature Correlation Matrix'

Use case: Feature selection and multicollinearity check.


8. Time Series Line Plot with Anomalies Highlighted

Prompt:

Given a DataFrame 'df' with datetime index and column 'value',
plot the time series as a line.
Identify points where value is more than 3 standard deviations from the rolling mean (window=30 days)
and highlight them as red scatter points on the same plot.
Add a horizontal dashed line at the overall mean.

Use case: Monitoring dashboards for anomalies.


9. Grouped Bar Plot with Error Bars

Prompt:

Using seaborn, create a grouped bar plot from DataFrame 'df' with:
- x: 'category'
- hue: 'group'
- y: 'metric'
Add error bars showing standard deviation.
Set style to 'whitegrid', palette to 'Set2'.
Annotate each bar with its height value.

Use case: Comparing metrics across categories and groups (e.g., A/B test results).


10. Custom Pairplot with Regression Lines

Prompt:

From a DataFrame with numeric columns ['age', 'income', 'spend', 'satisfaction'],
create a pairplot using seaborn with:
- Diagonal: histograms
- Off-diagonal: scatter plots with regression lines
- Color by 'segment' column (categorical)
- Marker size: 20, alpha: 0.6

Use case: Multivariate EDA for segmentation.


Prompts for Statistical Analysis & Modeling

11. A/B Test Significance Check

Prompt:

Given two arrays: control_revenue and treatment_revenue.
Perform a two-sample t-test (independent, unequal variance).
Print:
- p-value
- mean difference with 95% confidence interval
- Cohen's d effect size
- Interpretation: is the result statistically significant at alpha=0.05?

Use case: Quick hypothesis testing without opening a stats textbook.


12. Feature Importance from Random Forest

Prompt:

Train a Random Forest classifier on DataFrame 'df' with target column 'churned'.
- Use all other columns as features (handle categoricals with one-hot encoding)
- Split 80/20 train/test
- Print accuracy, precision, recall, F1 on test set
- Plot feature importance (top 15) as horizontal bar chart
- Save the model as 'rf_model.pkl'

Use case: Baseline model + interpretability.


13. Outlier Detection with IQR

Prompt:

Write a function that takes a DataFrame and a column name.
It should identify outliers using the IQR method (1.5 * IQR rule).
Return:
- Number of outliers
- Indices of outlier rows
- A new DataFrame with a column 'is_outlier' (bool)
- A boxplot highlighting outliers in red

Use case: Data quality check before modeling.


14. Rolling Statistics for Financial Data

Prompt:

Given a DataFrame 'prices' with columns ['date', 'close'],
calculate and plot:
- 20-day simple moving average
- 50-day simple moving average
- Bollinger Bands (20-day SMA ± 2 * 20-day std)
- Daily returns
All on the same figure with different colors and a legend.

Use case: Technical analysis for any time series.


15. Automated EDA Report

Prompt:

Write a Python script that, given a DataFrame 'df', generates an HTML report containing:
- Table of missing values per column
- Histograms for all numeric columns (arranged in a grid)
- Count plots for all categorical columns (max 10 unique values)
- Correlation heatmap
- Boxplots for numeric columns grouped by a categorical column (choose the one with most categories)
Save as 'eda_report.html' and open in browser.

Use case: Shareable EDA output with non-technical stakeholders.


Putting It All Together: A Real-World Workflow

Let's say you're a data scientist at a subscription box company. You receive a CSV with 6 months of customer data: signup dates, plan types, monthly revenue, and churn status.

  1. Start with Prompt #1 — profile the data to see missing values and distributions.
  2. Clean with Prompt #2 — impute missing revenue using plan-type averages.
  3. Engineer features with Prompt #5 — create customer-level metrics.
  4. Visualize churn patterns with Prompt #9 — grouped bar of churn rates by plan type.
  5. Build a model with Prompt #12 — random forest to predict churn, plot top features.
  6. Report with Prompt #15 — generate an HTML EDA report for the product team.

This entire pipeline can be driven by prompts, each producing production-quality code in seconds.


Tips for Writing Better Data Science Prompts

  • Be specific about column names and data types. The AI can't guess your schema.
  • Provide a small sample of data. Include df.head().to_dict() in your prompt.
  • State the output format. "Return a DataFrame", "Print a summary", "Save as PNG".
  • Mention libraries and versions. "Using pandas 2.0+" avoids deprecated syntax.
  • Include error handling. "If column missing, skip gracefully."

Conclusion

Prompts are not replacements for understanding — they are accelerators. The 15 prompts above cover the most common tasks in data analysis, pandas manipulation, and visualization. Copy them, adapt them to your data, and watch your productivity multiply.

Remember: the best prompt is the one that gets you from question to insight in the fewest steps. Keep refining your prompts as you learn what works. Happy analyzing!

← All posts

Comments