From Messy Data to Model Mastery: 15 Data Science Prompts That Actually Work

You've cleaned data, built models, and tuned hyperparameters. But what if you could skip the tedious parts and focus on the insights? The secret isn't a magic tool — it's how you talk to AI. Large language models (LLMs) have become surprisingly competent data science assistants. The catch? You need to know the right prompts. This guide gives you 15 battle-tested prompts for data cleaning, EDA, visualization, modeling, and interpretation. No fluff, just prompts that work.

1. Data Cleaning: The 'Scrub-a-Dub-Dub' Prompt

Task: Automate the grunt work of data cleaning: missing values, outliers, inconsistent formats.

Prompt:

Act as a senior data scientist. I have a pandas DataFrame named 'df' with columns: [list columns]. Write Python code to:
1. Detect missing values and suggest a strategy for each column (e.g., mean imputation, drop, forward-fill).
2. Identify outliers using the IQR method and flag them.
3. Standardize column names to snake_case.
4. Convert date columns to datetime.
Explain each step with comments.

Example: For a customer dataset, this prompt generates code that flags missing age values, caps outliers in income, and renames CustomerID to customer_id.

2. Imputation: The 'Fill in the Blanks' Prompt

Task: Choose the right imputation technique based on data type and missingness.

Prompt:

I have a dataset with missing values. For each column, suggest the best imputation method (e.g., mean, median, mode, KNN, MICE) and justify your choice. Column types: [list]. Missingness percentage: [indicate]. Write Python code using sklearn's SimpleImputer or IterativeImputer.

Example: For a housing dataset with 30% missing garage_area, the prompt recommends median imputation because of outliers.

3. EDA: The 'Data Detective' Prompt

Task: Generate a comprehensive exploratory data analysis report.

Prompt:

Perform an EDA on the DataFrame 'df'. Produce a summary including:
- Descriptive statistics (mean, median, std, etc.)
- Correlation matrix (Pearson and Spearman) with heatmap
- Distribution plots for each numeric column (histogram, boxplot)
- Count plots for categorical columns
- Bivariate analysis: scatter plots for key pairs
Use seaborn and matplotlib. Write code that saves plots to 'eda_plots/'.

Example: This prompt creates a full report for a sales dataset, revealing a strong positive correlation between ad_spend and revenue.

4. Visualization: The 'Storyteller' Prompt

Task: Create publication-ready visualizations that tell a story.

Prompt:

Create 3 visualizations for the DataFrame 'df' to answer: [question]. Use matplotlib/seaborn. For each, explain the insight it conveys. Choose the most effective chart type (bar, line, scatter, etc.). Write clean code with custom colors and labels.

Example: For a churn dataset, the prompt generates a survival curve (Kaplan-Meier) and a feature importance chart.

5. Feature Engineering: The 'Feature Forge' Prompt

Task: Automatically generate meaningful features from raw data.

Prompt:

Suggest 5 new features for the DataFrame 'df' based on domain knowledge. For each feature, write Python code to create it. Consider interactions, aggregations, and time-based features. Provide a rationale for each.

Example: For a retail dataset, it creates days_since_last_purchase, total_spend_last_30d, and purchase_frequency.

6. Model Selection: The 'Compare and Contrast' Prompt

Task: Choose the best model for a classification/regression task.

Prompt:

I'm solving a [classification/regression] problem with 'target' as the target. Write Python code to:
1. Split data into train/test.
2. Train 5 models: [list, e.g., Logistic Regression, Random Forest, XGBoost, LightGBM, Neural Net].
3. Compare using [accuracy/F1/RMSE] with cross-validation.
4. Print a comparison table and identify the best model.

Example: For a fraud detection task, the prompt compares models and finds XGBoost has the best F1-score.

7. Hyperparameter Tuning: The 'Fine-Tuner' Prompt

Task: Optimize hyperparameters efficiently.

Prompt:

Use Optuna to tune hyperparameters for [model] on the 'df' dataset. Define the objective function, suggest hyperparameter ranges, and run 50 trials. Print the best parameters and score. Provide code.

Example: Tuning a Random Forest on a marketing dataset improves ROC-AUC from 0.82 to 0.87.

8. Cross-Validation: The 'Avoid Overfitting' Prompt

Task: Implement robust cross-validation for model evaluation.

Prompt:

Write Python code to perform stratified k-fold cross-validation (k=5) on 'df' for a classification problem. For each fold, train [model], record the F1-score, and report the mean and std. Also, plot the ROC curve for each fold.

Example: The prompt reveals that a previous model's high accuracy was due to data leakage.

9. Model Interpretation: The 'Black Box Opener' Prompt

Task: Explain model predictions using SHAP or LIME.

Prompt:

Using the trained model from above, calculate SHAP values for the test set. Produce:
- A summary plot (beeswarm)
- A bar plot of mean absolute SHAP values
- An explanation for a single prediction (use force plot)
Write code using the shap library.

Example: For a credit risk model, the prompt reveals that credit_utilization is the top predictor.

10. Time Series: The 'Forecast Guru' Prompt

Task: Build a time series forecast with ARIMA or Prophet.

Prompt:

I have a time series of [variable] with daily frequency. Write Python code to:
1. Check stationarity (ADF test).
2. Fit an ARIMA model (auto-select p, d, q using pmdarima).
3. Forecast the next 30 days and plot the confidence interval.
4. Evaluate with MAE and RMSE.

Example: This prompt forecasts website traffic for the next month, helping with capacity planning.

11. Natural Language Processing: The 'Text Wrangler' Prompt

Task: Clean and vectorize text data for ML.

Prompt:

I have a text column 'review'. Write Python code to:
1. Clean text: remove HTML tags, punctuation, stopwords (use NLTK).
2. Apply stemming or lemmatization.
3. Vectorize using TF-IDF (max_features=1000) or Word2Vec.
4. Train a simple classifier (e.g., Logistic Regression) and report accuracy.

Example: For a product review dataset, the prompt builds a sentiment classifier with 85% accuracy.

12. Anomaly Detection: The 'Needle in a Haystack' Prompt

Task: Detect anomalies in data using isolation forests.

Prompt:

Write Python code to detect anomalies in 'df' using IsolationForest. Set contamination to 0.05. Visualize the anomalies in a 2D scatter plot (using PCA for dimensionality reduction). Print the number of anomalies and their indices.

Example: For network traffic data, the prompt identifies unusual patterns that may indicate cyberattacks.

13. A/B Testing: The 'Statistically Significant' Prompt

Task: Analyze A/B test results correctly.

Prompt:

I have A/B test results: control and treatment conversion rates. Write Python code to:
1. Perform a two-proportion z-test.
2. Calculate the p-value and confidence interval.
3. Determine if the result is statistically significant (alpha=0.05).
4. Suggest a minimum sample size for future tests (use power analysis).

Example: This prompt tells you whether a new landing page actually improves conversion or if it's due to chance.

14. Reporting: The 'AutoML Report' Prompt

Task: Generate a comprehensive model performance report.

Prompt:

Using the trained model, generate a report with:
- Classification report (precision, recall, F1)
- Confusion matrix (with plot)
- ROC-AUC score
- Feature importance (if applicable)
- Business insights (e.g., which segment has highest false positives)
Write Python code that outputs the report as a PDF using reportlab.

Example: For a churn prediction model, the report highlights that high-income customers are often misclassified.

15. Deployment: The 'API Ready' Prompt

Task: Prepare a model for deployment via an API.

Prompt:

Write Python code to save the trained model using joblib, then create a FastAPI app with a '/predict' endpoint that loads the model, takes input JSON, and returns predictions. Include input validation with Pydantic.

Example: This prompt turns your model into a REST API ready for integration.

These prompts aren't just shortcuts — they're a way to think. They force you to be specific about your data, your goals, and your constraints. The best AI data scientists are the ones who ask precise questions. So copy, tweak, and run. Your future self will thank you.

Want more? Check out our other articles on Python code generation and AI-powered workflows.

← All posts

Comments