30 Prompts for Data Science: Data Analysis, Visualization, and Pandas

Introduction

Data science is a hands-on craft. You spend most of your time cleaning data, transforming it, and building visualizations to uncover patterns. Large language models (LLMs) like ChatGPT, Claude, and Gemini can accelerate this workflow—but only if you know how to prompt them correctly. Generic prompts like "analyze this CSV" produce shallow results. Specific, battle-tested prompts generate production-ready code and actionable insights. This article collects 30 prompts I actually use in my daily data science work: 10 for Pandas, 10 for Matplotlib and Seaborn, and 10 for general data analysis. Each prompt includes a real usage example and a brief explanation of why it works. No fluff, no theory—just prompts you can copy and paste today.

10 Prompts for Pandas

Pandas is the Swiss Army knife of data manipulation in Python. These prompts cover common operations: filtering, grouping, merging, handling missing data, and performance optimization.

1. Filter rows based on multiple conditions

Prompt: "Generate Pandas code to filter a DataFrame df where column 'age' is greater than 30 and column 'city' is either 'New York' or 'Chicago'. Use boolean indexing and explain each step."

Usage example: You have a customer dataset and need to target users over 30 in specific cities. The LLM returns a code block with comments, making it easy to adapt.

# Filtering with multiple conditions
filtered_df = df[(df['age'] > 30) & (df['city'].isin(['New York', 'Chicago']))]

2. Group by and aggregate with multiple functions

Prompt: "Write Pandas code to group a DataFrame sales by 'region' and 'product', then calculate sum of 'revenue', average of 'quantity', and count of orders. Use agg() with a dictionary."

Usage example: Monthly sales reports require per-region and per-product summaries. The prompt ensures the output includes exactly the metrics you need.

3. Merge two DataFrames on multiple keys

Prompt: "Merge DataFrames orders and customers on columns 'customer_id' and 'order_date' using an inner join. Show the resulting shape and handle any duplicate column names with suffixes."

Usage example: Combining transaction data with customer profiles for churn analysis.

4. Handle missing values with custom logic

Prompt: "In a DataFrame df, fill missing values in numeric columns with the median, fill missing values in categorical columns with the mode, and drop rows where more than 50% of values are missing. Provide code and explain the rationale."

Usage example: Cleaning a messy survey dataset where different column types need different imputation strategies.

5. Apply a custom function to each row

Prompt: "Use df.apply() with a lambda function to create a new column 'score_category' that assigns 'low' if 'score' < 50, 'medium' if 50-80, and 'high' if > 80. Avoid using for loops."

Usage example: Categorizing test scores or risk ratings without writing a verbose loop.

6. Reshape data from wide to long format

Prompt: "Convert a wide-format DataFrame df_wide with columns 'id', '2023_sales', '2024_sales', '2025_sales' into a long format with columns 'id', 'year', 'sales'. Use pd.melt() and explain the parameters."

Usage example: Preparing data for time-series visualization where each year should be a separate row.

7. Detect and remove outliers using IQR

Prompt: "Write Pandas code to detect outliers in column 'price' using the interquartile range (IQR) method. Remove rows where price is below Q1 - 1.5IQR or above Q3 + 1.5IQR. Show the number of rows removed."

Usage example: Cleaning a real estate dataset before feeding it into a regression model.

8. Create a pivot table with margins

Prompt: "Generate a pivot table from DataFrame transactions with 'region' as index, 'year' as columns, sum of 'amount' as values, and include row and column totals (margins). Use pd.pivot_table()."

Usage example: Building an executive summary table for quarterly revenue by region.

9. Perform a rolling window calculation

Prompt: "Compute a 7-day rolling average of column 'daily_sales' in DataFrame sales_data sorted by 'date'. Add the result as a new column 'rolling_avg_7d'. Handle cases with fewer than 7 days at the start."

Usage example: Smoothing daily website traffic data to spot trends.

10. Optimize DataFrame memory usage

Prompt: "Analyze the memory usage of DataFrame df using df.info() and df.memory_usage(). Suggest specific dtype changes (e.g., downcast float64 to float32, convert object to category) and provide code to apply them."

Usage example: Reducing memory footprint before scaling up to a dataset with millions of rows.

10 Prompts for Matplotlib and Seaborn

Visualization is critical for exploratory data analysis (EDA) and communicating findings. These prompts generate publication-quality charts with minimal tweaking.

1. Create a multi-panel figure with shared axes

Prompt: "Using Matplotlib, create a 2x2 subplot figure where each subplot shows a different distribution: histogram of 'age', boxplot of 'income', scatterplot of 'age' vs 'income', and bar chart of 'education_level'. Share the x-axis where appropriate. Use plt.subplots() and set a suptitle."

Usage example: A single figure summarizing key variables in a demographic dataset.

2. Customize a Seaborn heatmap with annotations

Prompt: "Generate a heatmap of the correlation matrix for DataFrame df using Seaborn. Display correlation values inside cells, use a diverging color palette (coolwarm), set square cells, and mask the upper triangle. Add a title."

Usage example: Quickly identifying multicollinearity among features before modeling.

3. Build a time series line plot with multiple lines

Prompt: "Plot three time series columns ('sales', 'marketing_spend', 'website_visits') from DataFrame ts_data on the same figure. Use different line styles and a legend. Add gridlines and format the x-axis dates to show month and year."

Usage example: Visualizing how marketing spend and website visits correlate with sales over time.

4. Create a categorical bar plot with error bars

Prompt: "Using Seaborn, create a bar plot of average 'score' by 'treatment_group' with error bars representing the standard deviation. Use sns.barplot() and set the capsize parameter for the error bars."

Usage example: Presenting A/B test results with variability clearly shown.

5. Make a violin plot with split by hue

Prompt: "Generate a violin plot with Seaborn showing distribution of 'price' across 'category', split by 'gender' using the hue parameter. Set split=True and use a pastel palette."

Usage example: Comparing price distributions across product categories for male vs. female buyers.

6. Add annotations to a scatter plot

Prompt: "Create a scatter plot of 'height' vs 'weight' with Matplotlib. For the top 5 outliers (highest weight), annotate the points with the corresponding 'name' column. Use plt.annotate() with arrows."

Usage example: Highlighting extreme data points in a medical dataset.

7. Plot a cumulative distribution function (CDF)

Prompt: "Using Matplotlib, plot the empirical CDF of column 'response_time' from DataFrame df. Use np.linspace() to generate percentiles and np.percentile() to compute values. Add vertical lines at the 25th, 50th, and 75th percentiles."

Usage example: Understanding latency distribution in a server log dataset.

8. Create a paired bar chart with Seaborn

Prompt: "Plot a paired bar chart comparing 'before' and 'after' scores for each subject in DataFrame pre_post. Use sns.barplot() with 'subject' on x-axis and 'score' on y-axis, and hue='timepoint'. Add a legend."

Usage example: Visualizing pre-test and post-test results in an educational experiment.

9. Design a custom color palette

Prompt: "Create a custom discrete color palette using Matplotlib's ListedColormap with hex colors: #FF6B6B, #4ECDC4, #45B7D1, #96CEB4. Apply it to a Seaborn bar plot of 'sales' by 'region'. Set the palette using the palette parameter."

Usage example: Brand-consistent colors for a corporate presentation.

10. Save a figure with high resolution and tight layout

Prompt: "After creating a Matplotlib figure, save it as 'figure.png' with 300 DPI, tight layout, and no white borders. Use plt.savefig() with bbox_inches='tight' and pad_inches=0.1. Also show the code to display the figure inline in a Jupyter notebook."

Usage example: Exporting a figure for publication or sharing on a blog.

10 Prompts for General Data Analysis

These prompts go beyond coding and help you design analysis workflows, interpret results, and communicate findings.

1. Design an EDA checklist

Prompt: "Act as a senior data scientist. Generate a step-by-step exploratory data analysis (EDA) checklist for a new dataset with 50 columns and 100,000 rows. Include steps for data quality checks, univariate analysis, bivariate analysis, and multivariate analysis. Suggest specific visualizations for each step."

Usage example: Starting a new project and need a repeatable process.

2. Interpret a correlation matrix

Prompt: "Given a correlation matrix with these values: (provide matrix). Identify which pairs of variables are strongly correlated (|r| > 0.7), suggest possible reasons for the correlations, and recommend whether to remove one variable from each pair before building a linear model. Explain multicollinearity in simple terms."

Usage example: Deciding which features to keep in a regression model.

3. Write a data cleaning function

Prompt: "Write a reusable Python function clean_dataset(df) that: (1) removes duplicate rows, (2) standardizes column names to snake_case, (3) converts date columns to datetime, (4) imputes missing numeric values with median, (5) drops columns with >80% missing values. Include docstring and type hints."

Usage example: Automating cleaning across multiple similar datasets.

4. Compare two distributions with statistical tests

Prompt: "I have two samples: control_group = [list of values] and treatment_group = [list of values]. Perform a two-sample Kolmogorov-Smirnov test and a t-test. Interpret the p-values and explain whether the distributions are significantly different. Provide Python code using scipy.stats."

Usage example: Evaluating if a website redesign changed user behavior.

5. Generate a data profiling report

Prompt: "Using the ydata-profiling library (formerly pandas-profiling), generate a profile report for DataFrame df. Save it as an HTML file named 'profile_report.html'. Then list the top 5 insights a data scientist should examine first from the report."

Usage example: Quick initial exploration of a new dataset.

6. Suggest feature engineering ideas

Prompt: "Given a dataset with columns: 'timestamp', 'user_id', 'page_views', 'session_duration', 'device_type', 'country', 'purchased' (target). Suggest 5 feature engineering ideas that could improve a classification model. For each idea, explain the rationale and provide a code snippet."

Usage example: Boosting model performance before hyperparameter tuning.

7. Detect data drift between two periods

Prompt: "I have two DataFrames: df_jan and df_feb with the same schema. Write code to detect data drift by comparing distributions of numeric columns using Kullback-Leibler divergence and categorical columns using chi-square test. Flag columns where drift is significant (KL > 0.1 or p-value < 0.05)."

Usage example: Monitoring model performance in production when data distribution shifts.

8. Build a simple churn prediction pipeline

Prompt: "Outline a complete data science pipeline for predicting customer churn. Include steps: data collection, feature engineering (e.g., tenure, usage frequency, support tickets), model selection (logistic regression vs random forest), evaluation metrics (precision, recall, ROC AUC), and deployment strategy. Provide code for the core modeling step using scikit-learn."

Usage example: A template for starting a churn analysis project.

9. Explain an anomaly detection approach

Prompt: "I have a time series of server CPU usage. Suggest an unsupervised anomaly detection method using Isolation Forest. Explain how to set the contamination parameter, visualize anomalies, and interpret the results. Provide Python code with sklearn.ensemble.IsolationForest."

Usage example: Detecting infrastructure issues before they cause outages.

10. Summarize findings for non-technical stakeholders

Prompt: "Act as a data science consultant. You analyzed a customer satisfaction survey and found that: (1) response time is the strongest predictor of satisfaction, (2) customers aged 25-34 are the most satisfied, (3) mobile app users are less satisfied than web users. Write a one-page executive summary with bullet points, a key visualization description, and three actionable recommendations. Avoid jargon."

Usage example: Preparing a slide deck for a product team meeting.

Conclusion

These 30 prompts are a starting point, not a final list. The most effective prompts are specific, include context about your data, and ask for explanations alongside code. As you use LLMs in your workflow, you'll develop your own library of prompts that reflect your domain and tools. The key is to treat the AI as a collaborator: tell it what you need, show it examples, and iterate. Copy these prompts, adapt them to your datasets, and watch your productivity multiply. Happy analyzing!

All code examples in this article are tested with Python 3.12, Pandas 2.2, Matplotlib 3.8, and Seaborn 0.13. For an interactive learning path covering Pandas, visualization, and machine learning, explore the project-based courses at asibiont.com/blog.

← All posts

Comments