Generate Python Data Analysis Script
When you need to automate a data analysis task in Python and want a ready-to-run script.
Prompt
You are a data analyst Python expert. Write a Python script using pandas and [OTHER_LIBRARIES, e.g., numpy, matplotlib] to perform the following analysis: [ANALYSIS_TASK]. The input data is [DATA_SOURCE, e.g., CSV file path, database], with columns [COLUMN_NAMES_AND_TYPES]. The output should be [OUTPUT_FORMAT, e.g., a summary table, a chart, a cleaned file]. Include comments, error handling, and follow PEP8. Output only the code and a brief explanation.
Fill in these
Swap each placeholder for your own value:
[OTHER_LIBRARIES][ANALYSIS_TASK][DATA_SOURCE][COLUMN_NAMES_AND_TYPES][OUTPUT_FORMAT]
Pro tips
- Specify the environment or virtual environment constraints.
- Ask for the script to be modular with functions for reuse.
- Request a dry-run version that prints steps instead of modifying files.
Related prompts
Complex Conditional Formula Generator
Act as a spreadsheet expert. I need a formula for [SPREADSHEET_APP] to calculate [DESIRED_OUTCOME] based on these conditions: [CONDITIONS]. The formula should handle [DATA_RANGE_REFERENCE] and include [SPECIFIC_FUNCTIONS, e.g., IF, VLOOKUP, INDEX-MATCH]. Use best practices for readability and error handling. Output only the formula with a brief explanation of how it works.
View promptClean Messy Text Columns with Formulas
I have a spreadsheet column containing [DATA_TYPE, e.g., full names, addresses, email addresses] that is inconsistently formatted. Common issues include [LIST_ISSUES, e.g., extra spaces, mixed case, inconsistent separators]. Please provide a set of formulas or functions in [SPREADSHEET_APP] to clean this column, transforming the data into a consistent format: [DESIRED_FORMAT]. Include explanations for each formula step. If a single formula is too complex, break it down into helper columns.
View promptConvert Natural Language to SQL Query
You are a SQL expert. I will provide a description of my database tables and a question. Write a SQL query to answer the question. Use clear aliases, comments, and optimize for readability. Tables: [TABLE_SCHEMAS]. Question: [QUESTION]. Include only the SQL code in your response, with a brief explanation after.
View promptExplain Data Trend or Anomaly
I have a dataset about [DATASET_DESCRIPTION]. I observed a [TREND_OR_ANOMALY] between [TIME_PERIOD_OR_SEGMENT]. My hypothesis is [YOUR_HYPOTHESIS, if any]. Help me interpret this finding. Consider factors such as [RELEVANT_FACTORS]. Provide possible explanations, suggest additional data to analyze, and ask me clarifying questions to narrow down causes.
View prompt