This guide was written in 2023 and was flagged as referring to the GPT-4 era. Model capabilities and file-handling features change, so check the official documentation before relying on any step.
Quick answer
Good ChatGPT prompts for data science state the question, dataset grain, columns and types, constraints and desired output. Ask the model to state assumptions, flag missing information, not invent values and return reproducible code. Always verify results against the real data and keep a human review.
ChatGPT prompts for data science work best when they describe the data, the decision, the constraints, and the form of the output. Use the templates below to plan an analysis, write safer code, compare models, explain results, and communicate findings. Replace every bracketed placeholder with your own context, and verify the output against the real data before using it.
Quick answer: how to prompt ChatGPT for data science
Give the model five things: the business or research question, the dataset grain, the columns and data types, the required constraints, and the desired deliverable. Ask it to state assumptions, show checks, and separate observed results from hypotheses. A useful prompt also tells ChatGPT not to invent values, to flag missing information, and to return reproducible code with a short explanation.
Context + data dictionary + task + constraints + validation checks + output format
40 practical ChatGPT prompts for data science
1. Scope and plan the project
- Project plan: “Act as a senior data scientist. I need to answer [question] for [audience]. My data is at the [row] level and contains [columns]. Propose an analysis plan with objectives, assumptions, risks, milestones, and a definition of done.”
- Data dictionary: “Turn this column list into a data dictionary with business meaning, data type, expected range, missing-value risks, and validation checks. Ask questions where the meaning is ambiguous.”
- Metric design: “Define [metric] precisely for [business context]. Include numerator, denominator, grain, time window, exclusions, edge cases, and one SQL-style validation query.”
- Experiment design: “Design an experiment to test whether [intervention] changes [outcome]. Recommend the unit of randomization, primary metric, guardrails, sample-size considerations, and threats to validity.”
- Reproducibility checklist: “Create a checklist for making this analysis reproducible: environment, data snapshot, random seeds, feature transformations, model version, evaluation split, and saved artifacts.”
2. Profile and clean a dataset
- Initial profile: “Write Python pandas code to profile [dataset]. Report shape, dtypes, missingness, unique counts, duplicates, quantiles, suspicious values, and possible leakage. Do not silently modify the data.”
- Cleaning plan: “Given this data-quality report, recommend a cleaning plan. For each issue, explain whether to fix, exclude, impute, or investigate; include the downside of each choice.”
- Missing values: “Analyze missingness in [columns]. Distinguish structural missingness from data-collection failure, suggest an imputation strategy, and show how to compare results with and without imputation.”
- Outliers: “Identify possible outliers in [dataset] using robust rules appropriate for [domain]. Return code that flags them for review and explain why deletion may be unsafe.”
- Join audit: “I am joining [table A] to [table B] on [keys]. Show how to check key uniqueness, row multiplication, unmatched records, and changes in totals before and after the join.”
- Privacy review: “Review this proposed analysis for personal or confidential data. List minimization, aggregation, masking, access-control, retention, and disclosure risks. Do not infer identity from the sample.”
3. Explore data and choose visualizations
- EDA sequence: “Create a step-by-step exploratory data analysis plan for [dataset] that starts with data quality, then distributions, relationships, segments, time patterns, and sensitivity checks.”
- Chart selection: “Recommend the best chart for showing [comparison or relationship] across [variables]. Explain what a chart could hide and provide an accessible alternative.”
- Trend analysis: “Analyze [metric] over [time period]. Separate trend, seasonality, calendar effects, breaks, and uncertainty. List hypotheses to test rather than claiming causes from correlation.”
- Segmentation: “Suggest defensible ways to segment [entities] using [features]. Compare rule-based, clustering, and supervised approaches, including interpretability and stability checks.”
- Insight review: “Here are summary statistics and charts. Identify the strongest supported findings, surprising patterns, possible confounders, and the next analysis that would reduce uncertainty.”
4. Build and evaluate machine-learning models
- Baseline: “Build a leakage-safe baseline for predicting [target] from [features]. Use an appropriate train/validation/test strategy, a simple benchmark, and metrics tied to [decision]. Explain every preprocessing step.”
- Classification: “Compare [models] for [classification task]. Use cross-validation, class-imbalance handling inside each fold, probability calibration, and metrics including [precision/recall/AUC]. Recommend a threshold based on costs.”
- Regression: “Create a regression workflow for [target]. Check the target distribution, compare MAE and RMSE, inspect residuals, and explain when a log transform or robust loss would be appropriate.”
- Time series: “Forecast [target] at [frequency] for [horizon]. Use a time-ordered split, naive and seasonal baselines, rolling validation, and prediction intervals. Do not shuffle future observations into training.”
- Feature engineering: “Suggest feature engineering for [dataset] while preventing target leakage. For each feature, give the calculation window, availability time, missing-value behavior, and a test.”
- Hyperparameter search: “Write reproducible code for a bounded hyperparameter search over [model]. Keep preprocessing inside the pipeline, optimize [metric], log the search space, and reserve a final holdout set.”
- Imbalanced data: “For [imbalanced task], compare class weights, threshold tuning, and resampling. Apply resampling only inside training folds and explain which metrics should guide the decision.”
- Model comparison: “Create a model comparison table with metric mean, standard deviation, calibration, training cost, inference cost, interpretability, and failure modes. Avoid declaring a winner from one split.”
5. Explain, debug, and document results
- Explainability: “Explain this model’s predictions using a global and local method appropriate for [model and data]. Distinguish association from causation and identify explanations that may be unstable.”
- Error analysis: “Given these predictions and actual outcomes, create an error-analysis plan by segment, confidence, time period, and data-quality flag. Prioritize errors by business impact.”
- Code review: “Review this Python or SQL for correctness, leakage, reproducibility, performance, security, and maintainability. Return findings by severity and a corrected version only where justified.”
- Unit tests: “Write tests for this transformation. Include normal cases, empty input, missing values, duplicate keys, unexpected categories, timezone boundaries, and conservation of totals.”
- Technical summary: “Turn these results into a methods section for a technical audience. Include data, assumptions, split strategy, metrics, uncertainty, limitations, and reproducibility details.”
- Executive summary: “Summarize these validated findings for [audience] in five bullets: what changed, how confident we are, business impact, caveats, and the next decision.”
6. SQL, Python, and workflow prompts
- SQL: “Write SQL for [question] using tables [names] and keys [keys]. First describe the grain, then provide the query, assumptions, duplicate-row risks, and checks for null or unmatched keys.”
- Pandas: “Write clear pandas code for [task]. Preserve the original DataFrame, use explicit column names, avoid chained assignment, and include a small validation output after each major step.”
- Translation: “Translate this [Python/R/SQL] code into [target language]. Preserve behavior, explain incompatible functions, and list tests that confirm equivalent results.”
- Performance: “Profile this code for [input size]. Identify the likely bottleneck, propose two optimizations, and design a benchmark that measures runtime, memory, and correctness.”
- Pipeline design: “Design a batch or streaming pipeline from [source] to [destination]. Include schema checks, idempotency, retries, monitoring, late data, backfills, and alert thresholds.”
A safer workflow for using these prompts
- Start with a small sample: confirm the schema and expected output before sharing a larger dataset.
- Remove sensitive fields: minimize personal, financial, health, credential, and proprietary information.
- Ask for assumptions: require the model to mark unknowns instead of filling gaps with invented facts.
- Run the code yourself: inspect queries, dependencies, file paths, and permissions before execution.
- Validate independently: compare totals, use a known baseline, inspect edge cases, and review domain logic.
- Record provenance: save the prompt, data version, code, model settings, evaluation results, and human decisions.
What ChatGPT should not do alone
ChatGPT can draft code and suggest hypotheses, but it cannot replace data access controls, statistical review, domain expertise, or production monitoring. Treat generated code as a draft. Never accept a model score, causal claim, privacy conclusion, or high-stakes recommendation without checking the underlying data and method.
FAQ
Can ChatGPT analyze a CSV or spreadsheet?
It can help inspect an uploaded or pasted dataset when the available ChatGPT workflow supports that file type. Start with a small, de-identified sample, state the question, and ask for a profile before requesting conclusions. Verify every important number against the source data.
How do I stop ChatGPT from inventing data-science results?
Tell it not to invent values, to list missing inputs, to label assumptions, and to return code or a reproducible calculation instead of an unsupported result. Then run the calculation and compare totals with an independent method.
What should I include in a data-science prompt?
Include the decision or question, dataset grain, column definitions, time boundaries, target, constraints, success metric, tools, and desired output. Mention privacy requirements and how you want uncertainty and limitations reported.
Final takeaway
The best ChatGPT prompts for data science are specific, testable, and honest about uncertainty. Use the templates as starting points, keep preprocessing and evaluation reproducible, and make a human review part of every important analysis.
For related prompt workflows, explore our ChatGPT copywriting prompts, ChatGPT marketing prompts, and guide to writing better GPT-4 prompts.
For a reusable prompt workflow beyond this data-science guide, see the PromptsHeaven prompt database and the Complete Playbook Bundle.