From 5 Hours to 5 Minutes: 12 Prompts for Data Science & Visualization That Actually Work

If you're a data scientist, you know the drill: messy CSVs, endless pandas wrangling, and the eternal struggle to explain your findings to stakeholders who just want a pretty chart. According to a 2023 survey by Anaconda, data scientists spend up to 45% of their time on data preparation and visualization tasks—not on modeling. That's precious hours you could spend on actual analysis.

But here's the good news: modern AI assistants, like the ones you can integrate with tools like ASI Biont, can slash that time dramatically. With the right prompts, you can automate repetitive code, generate insights, and create visualizations in minutes. In this guide, I'll share 12 battle-tested prompts that cover the full data science workflow—from cleaning to storytelling—each with a concrete example and a tip for customization.

Whether you're a seasoned pro or just starting, these prompts will help you work smarter, not harder. Let's dive in.

1. Data Cleaning: The "Messy CSV" Prompt

The Prompt:

I have a CSV file named 'sales_data.csv' with columns: date, product, region, units_sold, price, and revenue. The data has duplicates, missing values, and inconsistent date formats. Write Python code to:
- Load the data into a pandas DataFrame.
- Remove duplicate rows based on all columns.
- Convert the 'date' column to datetime, handling errors.
- Fill missing 'revenue' values with the median revenue.
- Normalize the 'region' column to title case.
- Output the cleaned DataFrame summary.

Why It Works: This prompt gives the AI clear instructions on what to do, including the data schema and specific operations. It's like giving a junior analyst a to-do list.

Example Output: The AI generates code like:

import pandas as pd

df = pd.read_csv('sales_data.csv')
df = df.drop_duplicates()
df['date'] = pd.to_datetime(df['date'], errors='coerce')
df['revenue'] = df['revenue'].fillna(df['revenue'].median())
df['region'] = df['region'].str.title()
print(df.info())
print(df.head())

Adaptation Tip: Replace the column names and operations with your own. For example, if you have categorical data, ask for one-hot encoding or label encoding.

2. Exploratory Data Analysis (EDA): The "First Glance" Prompt

The Prompt:

Given a pandas DataFrame 'df' with numerical and categorical columns, write Python code to perform a comprehensive EDA. Include:
- Summary statistics for numerical columns.
- Missing value analysis (count and percentage).
- Correlation matrix for numerical columns, visualized with a heatmap.
- Count plots for all categorical columns.
- Box plots to detect outliers for numerical columns.
- Pairplot for the first 5 numerical columns.

Why It Works: This prompt structures the EDA, ensuring you don't miss critical checks. It's a great starting point for any dataset.

Example Output: The AI will generate code using seaborn and matplotlib, producing a series of plots. The correlation heatmap helps you spot multicollinearity, and the box plots reveal outliers.

Adaptation Tip: Specify which columns are of interest. For example, if you're doing a churn analysis, ask for churn vs. tenure plots.

3. Feature Engineering: The "Create Features" Prompt

The Prompt:

I have a DataFrame 'df' with a 'purchase_date' column and a 'customer_id' column. Write Python code to create the following features:
- 'recency': days since the last purchase per customer.
- 'frequency': number of purchases per customer.
- 'monetary': total spend per customer.
- 'tenure': number of days between first and last purchase.
- 'weekday': day of the week for each transaction.
- 'is_weekend': 1 if weekend, else 0.

Why It Works: Feature engineering is often the most time-consuming part. This prompt automates the process, giving you a ready-to-use RFM analysis.

Example Output:

import pandas as pd

# Assuming df has 'customer_id' and 'purchase_date' and 'amount'
df['purchase_date'] = pd.to_datetime(df['purchase_date'])
df['weekday'] = df['purchase_date'].dt.dayofweek
df['is_weekend'] = df['weekday'].apply(lambda x: 1 if x >= 5 else 0)

# Recency, frequency, monetary, tenure
agg = df.groupby('customer_id').agg(
    recency=('purchase_date', lambda x: (df['purchase_date'].max() - x.max()).days),
    frequency=('purchase_date', 'count'),
    monetary=('amount', 'sum'),
    tenure=('purchase_date', lambda x: (x.max() - x.min()).days)
)

Adaptation Tip: Tailor the features to your business problem—for instance, add time-based features like 'days_since_last_click'.

4. Model Selection: The "Compare Algorithms" Prompt

The Prompt:

I have a classification problem with a target column 'churn' and several features. Write Python code to evaluate multiple classifiers using cross-validation. Use the following models: Logistic Regression, Random Forest, Gradient Boosting, and SVM. For each, calculate accuracy, precision, recall, and F1-score. Print a comparison table.

Why It Works: This prompt gives you a quick benchmark of models, saving you from writing repetitive loops.

Example Output:

from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier
from sklearn.svm import SVC
from sklearn.metrics import make_scorer, accuracy_score, precision_score, recall_score, f1_score

models = {
    'Logistic Regression': LogisticRegression(),
    'Random Forest': RandomForestClassifier(),
    'Gradient Boosting': GradientBoostingClassifier(),
    'SVM': SVC()
}

for name, model in models.items():
    scores = cross_val_score(model, X, y, cv=5, scoring='accuracy')
    print(f"{name}: {scores.mean():.3f} (+/- {scores.std():.3f})")

Adaptation Tip: Add hyperparameter tuning options, or ask for a specific scoring metric like ROC-AUC.

5. Hyperparameter Tuning: The "Grid Search" Prompt

The Prompt:

For a Random Forest classifier, write Python code to perform a grid search over the following hyperparameters: n_estimators (50, 100, 200), max_depth (None, 10, 20), and min_samples_split (2, 5, 10). Use 5-fold cross-validation and optimize for F1-score. Print the best parameters and the best score.

Why It Works: Hyperparameter tuning is tedious; this prompt automates it with GridSearchCV.

Example Output:

from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import GridSearchCV

param_grid = {
    'n_estimators': [50, 100, 200],
    'max_depth': [None, 10, 20],
    'min_samples_split': [2, 5, 10]
}

grid = GridSearchCV(RandomForestClassifier(), param_grid, cv=5, scoring='f1')
grid.fit(X, y)
print(grid.best_params_)
print(grid.best_score_)

Adaptation Tip: Change the hyperparameters to match your model. For XGBoost, you'd include learning_rate, etc.

6. Visualization: The "Quick Chart" Prompt

The Prompt:

I have a DataFrame 'df' with columns 'month', 'sales', and 'region'. Create a line plot showing monthly sales trends, with different lines for each region. Use a clear title, axis labels, and a legend. Save it as 'sales_trend.png'.

Why It Works: This prompt is straightforward and yields a publication-ready chart with minimal fuss.

Example Output:

import matplotlib.pyplot as plt
import seaborn as sns

plt.figure(figsize=(12, 6))
sns.lineplot(data=df, x='month', y='sales', hue='region')
plt.title('Monthly Sales Trends by Region')
plt.xlabel('Month')
plt.ylabel('Sales')
plt.legend(title='Region')
plt.savefig('sales_trend.png', dpi=300)
plt.show()

Adaptation Tip: Specify the chart type (bar, scatter, etc.) and any aesthetic preferences like color palette.

7. Interactive Dashboards: The "Plotly Dashboard" Prompt

The Prompt:

Create an interactive dashboard using Plotly Dash. The dashboard should have a dropdown to select a product category, and a bar chart showing total sales by region for that category. Also include a slider to filter by date range. Use sample data from a CSV file 'sales.csv'.

Why It Works: Interactive dashboards are powerful for stakeholders, and this prompt gives you a functional app skeleton.

Example Output: The AI will generate a Dash app with dcc.Dropdown, dcc.RangeSlider, and dcc.Graph. You can run it locally and share the link.

Adaptation Tip: Add more components like scatter plots or KPIs. You can also ask for a specific layout.

8. Time Series Forecasting: The "Prophet Forecast" Prompt

The Prompt:

Using the Prophet library, forecast the next 30 days of daily sales for a dataset with columns 'ds' (date) and 'y' (sales). Include holiday effects for Christmas and New Year. Plot the forecast with confidence intervals.

Why It Works: Prophet is a powerful library for time series, and this prompt sets it up correctly.

Example Output:

from prophet import Prophet
import pandas as pd

# df with 'ds' and 'y'
model = Prophet(holidays=holidays_df)  # you'd define holidays_df
model.fit(df)
future = model.make_future_dataframe(periods=30)
forecast = model.predict(future)
fig = model.plot(forecast)

Adaptation Tip: Adjust the forecast horizon and add custom seasonalities (e.g., weekly, yearly).

9. Natural Language Processing: The "Text Clean" Prompt

The Prompt:

I have a text column 'review' in a DataFrame. Write Python code to clean the text: remove punctuation, lowercase, remove stopwords, and apply stemming. Then create a word frequency distribution and a word cloud.

Why It Works: Text preprocessing is a common task, and this prompt handles it end-to-end.

Example Output:

import nltk
from nltk.corpus import stopwords
from nltk.stem import PorterStemmer
from wordcloud import WordCloud
import matplotlib.pyplot as plt

nltk.download('stopwords')
stop_words = set(stopwords.words('english'))
ps = PorterStemmer()

def clean_text(text):
    text = text.lower()
    text = ''.join([c for c in text if c.isalpha() or c.isspace()])
    words = text.split()
    words = [w for w in words if w not in stop_words]
    words = [ps.stem(w) for w in words]
    return ' '.join(words)

df['clean_review'] = df['review'].apply(clean_text)
# word frequency and word cloud...

Adaptation Tip: Use lemmatization instead of stemming for better results, or add custom stopwords.

10. Data Reporting: The "Stakeholder Summary" Prompt

The Prompt:

I've built a model that predicts customer churn. Write a concise summary for non-technical stakeholders. Include: the problem, the data used, the model's performance (accuracy, precision, recall), the top 3 features influencing churn, and actionable recommendations. Use plain language.

Why It Works: This prompt forces the AI to translate technical results into business language, saving you from writing lengthy emails.

Example Output: The AI will produce a paragraph like:

"We developed a model to predict which customers are likely to churn. Based on 10,000 customer records, our model correctly identifies 85% of churners (recall) with an overall accuracy of 82%. The most important factors are account tenure, number of support tickets, and monthly charges. We recommend proactive outreach to customers with high churn probability."

Adaptation Tip: Provide specific metrics and ask for a certain format (e.g., bullet points).

11. SQL: The "Query Generator" Prompt

The Prompt:

Write a SQL query to find the top 5 products by total revenue in the last quarter. The database has tables: 'orders' (order_id, product_id, order_date, quantity, price), 'products' (product_id, product_name). Use joins and aggregation.

Why It Works: SQL is a core skill, and this prompt gives you a correct query instantly.

Example Output:

SELECT p.product_name, SUM(o.quantity * o.price) AS total_revenue
FROM orders o
JOIN products p ON o.product_id = p.product_id
WHERE o.order_date >= DATE_TRUNC('quarter', CURRENT_DATE) - INTERVAL '3 months'
GROUP BY p.product_name
ORDER BY total_revenue DESC
LIMIT 5;

Adaptation Tip: Specify the SQL dialect (PostgreSQL, MySQL) and time period.

12. Automation: The "Scheduled Report" Prompt

The Prompt:

I need to automate a daily sales report. Write a Python script that:
- Reads a CSV file from a folder.
- Generates a summary table (total sales, top product, etc.).
- Creates a bar chart.
- Sends an email with the report as an attachment using SMTP.
- Schedule it with cron (or Windows Task Scheduler).

Why It Works: This prompt automates the entire reporting pipeline, saving you hours every day.

Example Output: The AI will provide a script with functions for each step, plus instructions for cron.

Adaptation Tip: Customize the email recipient list, SMTP server, and file paths.

Putting It All Together: A Real-World Workflow

Imagine you're a data scientist at an e-commerce company. You receive a new dataset with customer transactions. Instead of spending 5 hours on cleaning, EDA, and building a report, you could:

  1. Use Prompt #1 to clean the data (5 minutes).
  2. Use Prompt #2 for EDA (10 minutes).
  3. Use Prompt #3 to create RFM features (5 minutes).
  4. Use Prompt #4 to compare models (10 minutes).
  5. Use Prompt #6 to create visualizations for your slides (10 minutes).
  6. Use Prompt #10 to write the executive summary (5 minutes).

Total: ~45 minutes. You've just saved over 4 hours. That's the power of well-crafted prompts.

Conclusion

These 12 prompts are just the tip of the iceberg. The key to making them work is specificity: provide context, define your data, and state the expected output. As you use them, you'll learn to tweak them to your needs. Remember, AI is a tool, but you're the pilot.

Start with one prompt today. Integrate it into your workflow. You'll never go back to manual coding again. And if you want to take it even further, consider using a no-code AI agent like ASI Biont to connect these prompts to your data sources automatically. Happy analyzing!

← All posts

Comments