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

Introduction

Data science is the backbone of modern decision-making, and the ability to craft precise prompts—whether for AI assistants, code generation, or exploratory analysis—can dramatically accelerate your workflow. In 2026, the landscape of data science tools has matured: Pandas remains the gold standard for data manipulation in Python, while Matplotlib and Seaborn continue to dominate static visualization. However, the real game-changer is how you communicate with AI models to generate, debug, or optimize your code. This guide provides 10 ready-to-use prompts that cover the entire data science pipeline—from importing messy data to publishing publication-ready plots. Each prompt is designed to be copy-pasted into an AI assistant (e.g., ChatGPT, Claude, or a local LLM) and adapted to your specific dataset. We’ll walk through real-world examples, explain the logic behind each prompt, and share expert tips to avoid common pitfalls.

1. Data Loading and Initial Inspection

Prompt:

I have a CSV file named 'sales_data.csv' with columns: date, product_id, revenue, quantity, region. Write Pandas code to:
- Load the file with correct data types
- Display the first 5 rows
- Show summary statistics for numeric columns
- Check for missing values
- Print the number of unique values per column

Explanation:
This prompt covers the essential first step of any data science project: understanding your data. By specifying column names and desired actions, you avoid generic code. The AI will generate a complete script that you can run immediately.

Usage Example:

import pandas as pd

df = pd.read_csv('sales_data.csv', parse_dates=['date'])
print(df.head())
print(df.describe())
print(df.isnull().sum())
print(df.nunique())

2. Data Cleaning with Pandas

Prompt:

Given a DataFrame 'df' with columns: 'age', 'salary', 'email', 'signup_date'. Some 'age' values are negative, 'salary' has outliers above 1,000,000, and 'email' contains duplicates. Write Pandas code to:
- Replace negative ages with NaN
- Cap salary at the 99th percentile
- Drop duplicate emails keeping the first occurrence
- Convert signup_date to datetime and fill missing dates with the median date

Explanation:
Real-world data is messy. This prompt forces the AI to handle specific edge cases. The 99th percentile capping is a standard technique to mitigate outlier influence without deleting rows.

Usage Example:

df['age'] = df['age'].apply(lambda x: x if x >= 0 else None)
cap = df['salary'].quantile(0.99)
df['salary'] = df['salary'].clip(upper=cap)
df = df.drop_duplicates(subset='email', keep='first')
df['signup_date'] = pd.to_datetime(df['signup_date'], errors='coerce')
median_date = df['signup_date'].median()
df['signup_date'] = df['signup_date'].fillna(median_date)

3. Grouped Aggregation and Pivot Tables

Prompt:

Using the DataFrame 'df' with columns 'region', 'product', 'revenue', 'quantity', create:
- A grouped aggregation showing total revenue and average quantity per region
- A pivot table with regions as rows, products as columns, and sum of revenue as values
- A second pivot table with the same structure but showing count of transactions

Explanation:
Grouped aggregations are the bread and butter of data analysis. This prompt asks for both groupby and pivot_table, which are complementary. The second pivot table (count) helps identify sparse categories.

Usage Example:

grouped = df.groupby('region').agg({'revenue': 'sum', 'quantity': 'mean'})
pivot_rev = df.pivot_table(index='region', columns='product', values='revenue', aggfunc='sum', fill_value=0)
pivot_cnt = df.pivot_table(index='region', columns='product', values='revenue', aggfunc='count', fill_value=0)

4. Time Series Analysis with Date Resampling

Prompt:

The DataFrame 'df' has a datetime index and a column 'sales'. Write code to:
- Resample the data to weekly frequency using the mean
- Plot the original daily sales and the weekly resampled series on the same figure
- Add a rolling 4-week average to the weekly plot
- Highlight the period with maximum weekly sales

Explanation:
Time series resampling is critical for trend analysis. This prompt includes visualization and annotation, making it a complete mini-project.

Usage Example:

import matplotlib.pyplot as plt

weekly = df['sales'].resample('W').mean()
rolling = weekly.rolling(window=4).mean()

plt.figure(figsize=(12,6))
plt.plot(df.index, df['sales'], alpha=0.5, label='Daily')
plt.plot(weekly.index, weekly, label='Weekly Mean')
plt.plot(weekly.index, rolling, label='4-Week Rolling Avg')
plt.axvline(x=weekly.idxmax(), color='red', linestyle='--', label='Max Week')
plt.legend()
plt.show()

5. Statistical Testing with Pandas and SciPy

Prompt:

I have two groups in my DataFrame: 'control' and 'treatment' in column 'group', and a metric 'conversion_rate'. Write Python code to:
- Perform a two-sample t-test (assuming unequal variance) using scipy.stats
- Calculate Cohen's d effect size
- Create a boxplot comparing the two groups using Seaborn
- Print a summary table with mean, std, and sample size for each group

Explanation:
Statistical testing is a core skill for data scientists. This prompt integrates hypothesis testing, effect size, and visualization.

Usage Example:

from scipy import stats
import seaborn as sns
import numpy as np

ctrl = df[df['group']=='control']['conversion_rate']
treat = df[df['group']=='treatment']['conversion_rate']

t_stat, p_val = stats.ttest_ind(ctrl, treat, equal_var=False)
cohens_d = (treat.mean() - ctrl.mean()) / np.sqrt((ctrl.var() + treat.var()) / 2)

sns.boxplot(x='group', y='conversion_rate', data=df)
plt.show()

summary = df.groupby('group')['conversion_rate'].agg(['mean', 'std', 'count'])
print(summary)

6. Customizing Matplotlib Plots for Publication

Prompt:

Create a publication-ready line plot using Matplotlib with the following specifications:
- Data: x = [1,2,3,4,5], y = [2,4,6,8,10]
- Use a clean sans-serif font (e.g., 'Arial')
- Set figure size to 8x5 inches
- Add grid lines with alpha=0.3
- Label axes with units in brackets: 'Time (s)' and 'Velocity (m/s)'
- Add a legend in the upper left corner
- Save the figure as a high-resolution PNG (300 dpi)

Explanation:
Default Matplotlib plots look amateurish. This prompt teaches best practices for production-quality graphics.

Usage Example:

import matplotlib.pyplot as plt

plt.rcParams['font.family'] = 'Arial'
plt.figure(figsize=(8,5))
plt.plot([1,2,3,4,5], [2,4,6,8,10], label='Measured')
plt.xlabel('Time (s)')
plt.ylabel('Velocity (m/s)')
plt.grid(alpha=0.3)
plt.legend(loc='upper left')
plt.savefig('plot.png', dpi=300)
plt.show()

7. Seaborn Pairplot with Custom Color Mapping

Prompt:

Using the Iris dataset (seaborn.load_dataset('iris')), create a pairplot that:
- Colors points by species
- Uses a custom color palette: ['#FF6B6B', '#4ECDC4', '#45B7D1']
- Adds a kernel density estimate on the diagonal
- Changes marker style for each species (e.g., 'o', '^', 's')
- Saves the figure as 'iris_pairplot.png'

Explanation:
Seaborn’s pairplot is a powerful exploratory tool. This prompt customizes aesthetics beyond defaults.

Usage Example:

import seaborn as sns

iris = sns.load_dataset('iris')
palette = ['#FF6B6B', '#4ECDC4', '#45B7D1']
markers = {'setosa': 'o', 'versicolor': '^', 'virginica': 's'}
sns.pairplot(iris, hue='species', palette=palette, diag_kind='kde', markers=markers)
plt.savefig('iris_pairplot.png')
plt.show()

8. Handling Large Datasets with Chunking and Dask

Prompt:

I have a 5GB CSV file 'big_data.csv'. Write code to:
- Read the file in chunks of 100,000 rows using Pandas' read_csv with chunksize
- Calculate the mean of column 'value' across all chunks
- Also compute the 95th percentile of 'value' using incremental statistics (without loading all data)
- Print progress every 10 chunks

Explanation:
Large datasets cannot fit in memory. Chunking is a practical solution. For percentiles, you can use a running algorithm or simply collect a sample.

Usage Example:

chunksize = 100000
sum_val = 0
count = 0
percentile_data = []

for i, chunk in enumerate(pd.read_csv('big_data.csv', chunksize=chunksize)):
    sum_val += chunk['value'].sum()
    count += len(chunk)
    percentile_data.append(chunk['value'].quantile(0.95))
    if i % 10 == 0:
        print(f'Processed chunk {i}')

mean_val = sum_val / count
overall_percentile = np.mean(percentile_data)  # approximate
print(f'Mean: {mean_val}, Approx 95th Percentile: {overall_percentile}')

9. Automating Reporting with Jinja2 and Pandas

Prompt:

Write Python code to generate an HTML report from a DataFrame 'df' with columns 'month', 'revenue', 'cost'. The report should:
- Include a table showing month, revenue, cost, profit (revenue - cost)
- Highlight rows where profit is negative in red
- Add a bar chart of revenue and cost using Matplotlib, embedded as a base64 PNG
- Use a Jinja2 template with CSS styling
- Save the final report as 'report.html'

Explanation:
Automated reporting saves time. This prompt combines data manipulation, visualization, and templating.

Usage Example:

from jinja2 import Template
import base64
from io import BytesIO

# Calculate profit
df['profit'] = df['revenue'] - df['cost']

# Create plot
plt.figure()
df.plot(x='month', y=['revenue','cost'], kind='bar')
buf = BytesIO()
plt.savefig(buf, format='png')
buf.seek(0)
img_str = base64.b64encode(buf.read()).decode()

# Template
template_str = '''
<html>
<head><style>table {border-collapse: collapse;} td, th {border: 1px solid black; padding: 5px;}</style></head>
<body>
<h1>Monthly Report</h1>
<table>
<tr><th>Month</th><th>Revenue</th><th>Cost</th><th>Profit</th></tr>
{% for row in rows %}
<tr {% if row.profit < 0 %}style="background-color: red;"{% endif %}>
    <td>{{ row.month }}</td><td>{{ row.revenue }}</td><td>{{ row.cost }}</td><td>{{ row.profit }}</td>
</tr>
{% endfor %}
</table>
<img src="data:image/png;base64,{{ img }}" />
</body></html>
'''
template = Template(template_str)
html = template.render(rows=df.to_dict('records'), img=img_str)

with open('report.html', 'w') as f:
    f.write(html)

10. Integrating with APIs: Fetching and Analyzing Data

Prompt:

Write Python code to fetch daily exchange rates (USD to EUR) from the Frankfurter API (https://api.frankfurter.app) for the last 30 days. Then:
- Load the JSON response into a Pandas DataFrame
- Calculate the 7-day moving average
- Plot the original rates and moving average
- Print the date with the highest rate

Explanation:
Many data science tasks involve external APIs. This prompt teaches API integration with Pandas.

Usage Example:

import requests
import pandas as pd
import matplotlib.pyplot as plt

url = 'https://api.frankfurter.app/2026-06-13..2026-07-13?from=USD&to=EUR'
response = requests.get(url)
data = response.json()
rates = data['rates']
df = pd.DataFrame(list(rates.items()), columns=['date', 'rate'])
df['date'] = pd.to_datetime(df['date'])
df = df.sort_values('date')
df['ma7'] = df['rate'].rolling(7).mean()

plt.plot(df['date'], df['rate'], label='Original')
plt.plot(df['date'], df['ma7'], label='7-day MA')
plt.legend()
plt.show()

max_date = df.loc[df['rate'].idxmax(), 'date']
print(f'Highest rate on: {max_date.date()}')

ASI Biont supports connecting to external APIs like Frankfurter and many others through its flexible course platform. For more details, visit asibiont.com/courses.

Conclusion

These 10 prompts cover the essential spectrum of data science tasks—from data loading and cleaning to advanced visualization and API integration. The key is to be specific: the more context you provide (column names, desired outputs, edge cases), the better the AI’s response. As large language models continue to improve in 2026, they become powerful collaborators rather than mere code generators. Remember to always verify the output, especially statistical results, and adapt the prompts to your unique datasets. Happy data wrangling!

← All posts

Comments