20 of the best prompts for python scripts, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.

20 of the best prompts for python scripts, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
Published June 27, 2026
Getting Python Scripts right takes more than a single prompt. This 4-stage guide covers Plan Data Analysis Tasks, Write Data Manipulation Scripts, Refine and Optimize Code, and more, breaking the whole process into focused steps where each prompt builds on the last. Data analysts and scientists often spend excessive time writing and debugging Python scripts for data analysis, which can hinder productivity. This guide covers four essential stages: planning data analysis tasks, writing scripts for data manipulation, refining and optimizing code, and generating reports and visualizations. Users will produce efficient scripts that enhance their data analysis workflows. Every prompt is optimized and runs in ChatGPT, Claude, and Gemini.
This stage focuses on outlining the objectives and requirements for your data analysis project. A well-defined plan ensures that the subsequent scripts align with your goals and data sources.
Define objectives and data sources
Outline the objectives for your data analysis project by addressing the following points: 1. What is the main question you aim to answer: [QUESTION]? 2. What data sources will you use: [DATA SOURCES]? 3. What is the expected outcome of the analysis: [EXPECTED OUTCOME]? 4. What specific metrics or KPIs will you track: [METRICS]? 5. What is the timeline for completion: [TIMELINE]? This structured outline will help you clarify your analysis goals.
Identify key data cleaning steps
Identify the key data cleaning steps required for your analysis. Include the expected data types: [DATA TYPES], common issues to address: [ISSUES], cleaning techniques you plan to apply: [TECHNIQUES], tools or libraries you will use: [TOOLS], and the final format for your cleaned data: [FORMAT]. Provide a detailed explanation for each step to ensure a comprehensive understanding of your data cleaning process.
Outline data analysis methods
Outline a comprehensive plan for your data analysis tasks. Include the following elements: 1. List the statistical techniques you will apply: [TECHNIQUES]. 2. Identify any machine learning models you plan to consider: [MODELS]. 3. Specify the libraries you will utilize for the analysis: [LIBRARIES]. 4. Describe the expected challenges you might face during the analysis: [CHALLENGES]. 5. Define the criteria you will use to evaluate the results: [EVALUATION CRITERIA]. This outline will guide your data analysis process effectively.
Determine visualization requirements
Specify the visualization requirements for your data analysis. First, outline the key insights you want to visualize: [INSIGHTS]. Next, list the types of visualizations you plan to use, such as charts or graphs: [VISUALIZATION TYPES]. Then, identify the tools or libraries you will utilize for creating these visualizations: [VISUALIZATION TOOLS]. Additionally, describe the target audience for your visualizations: [AUDIENCE]. Finally, include any specific design preferences you have in mind: [DESIGN PREFERENCES]. This comprehensive overview will assist in developing your visualization scripts effectively.
Set up a project structure
Design a project structure for your data analysis scripts. Include the main directories you need, such as [DIRECTORIES], and specify the naming conventions for scripts, like [NAMING CONVENTIONS]. Outline the version control system to use, which should be [VERSION CONTROL], and detail the documentation requirements, including [DOCUMENTATION]. Additionally, list any resources needed for the project, such as [RESOURCES]. This structured approach will ensure your project remains organized and efficient.
In this stage, you will write Python scripts to manipulate and analyze your data based on the planning stage. This ensures that your scripts are aligned with your objectives and data requirements.
Create a data loading script
Write a Python script to load data from [DATA SOURCE]. Include the following elements: specify the libraries you will use, such as [LIBRARIES]; detail the data loading method, which should be [METHOD]; list any parameters necessary for loading, including [PARAMETERS]; implement error handling for potential loading issues, described as [ERROR HANDLING]; and include a confirmation message that indicates successful loading. This script will be crucial for your data analysis process.
Develop a data cleaning script
Write a Python script that performs data cleaning on the following data frame: [DATA FRAME]. Include the specific cleaning steps: [CLEANING STEPS], methods for handling missing values: [MISSING VALUE METHODS], and any necessary data type conversions: [DATA TYPE CONVERSIONS]. Finally, provide a summary of the cleaned data to ensure it is ready for analysis.
Implement data transformation functions
Create functions for data transformations in your analysis. Specify the transformation types you will implement: [TRANSFORMATION TYPES], and define the input data frame: [INPUT DATA FRAME]. Describe the expected output data frame structure: [OUTPUT STRUCTURE], and list any parameters required for the transformations: [PARAMETERS]. Finally, provide examples of the transformed data to illustrate the effectiveness of each function.
Write exploratory data analysis (EDA) scripts
Draft a Python script for exploratory data analysis (EDA) using the following details. First, specify the data frame to analyze: [DATA FRAME]. Next, outline the EDA techniques to apply: [TECHNIQUES]. Then, list the visualizations to create: [VISUALIZATIONS]. Include summary statistics to present: [STATISTICS]. Finally, describe any insights you expect to gain from this analysis: [EXPECTED INSIGHTS]. This comprehensive approach will help in understanding the dataset better.
Create a data export script
Write a Python script that exports the analyzed data from the data frame specified as [DATA FRAME]. The script should allow the user to choose the export format, which can be either [EXPORT FORMAT], and specify the file path for saving the exported file as [FILE PATH]. Additionally, include any necessary parameters for the export as [PARAMETERS] and implement a confirmation message that displays upon successful export to ensure the results are accessible.
This stage focuses on refining and optimizing your Python scripts to enhance performance and readability. Well-optimized code can significantly reduce execution time and improve maintainability.
Review and refactor code for readability
Examine the following Python scripts for readability: [SCRIPT]. Identify and analyze complex sections, suggesting improvements for variable names, comments, and documentation. Highlight any repetitive code and provide a revised version of the script that enhances clarity and maintainability.
Optimize performance of data processing
Analyze the following data processing scripts for performance optimization: [SCRIPT SNIPPET]. First, identify the key bottlenecks affecting performance: [BOTTLENECKS]. Next, suggest alternative libraries or methods that could improve efficiency: [ALTERNATIVES]. Additionally, recommend parallel processing techniques that can be applied: [PARALLEL TECHNIQUES]. Provide relevant code snippets to illustrate your optimization suggestions: [CODE SNIPPETS]. Finally, summarize the expected performance improvements from your recommendations.
Implement error handling best practices
Integrate error handling into your Python scripts by following these steps. First, identify potential error sources in your code: [ERROR SOURCES]. Next, suggest appropriate try-except blocks to manage these errors: [TRY-EXCEPT]. Then, recommend effective logging practices to track errors: [LOGGING PRACTICES]. Provide examples of informative error messages that can guide users: [ERROR MESSAGES]. Finally, summarize the importance of error handling in enhancing the robustness of your scripts.
Conduct code reviews with peers
Conduct a code review session with your peers focused on the following elements. First, provide the scripts to review: [SCRIPTS]. Next, outline the review criteria that will be used: [CRITERIA]. Describe the feedback process: [FEEDBACK PROCESS]. Identify any specific areas to focus on during the review: [FOCUS AREAS]. Finally, summarize the review outcomes, highlighting key areas for improvement and actionable suggestions.
Document code and usage instructions
Create comprehensive documentation for your Python scripts. Start with an overview of the project, detailing its purpose and goals: [PROJECT OVERVIEW]. Next, provide clear instructions for running the scripts, including any command-line arguments or configurations needed: [RUNNING INSTRUCTIONS]. Include detailed descriptions of key functions, explaining their roles and how to use them: [FUNCTION DESCRIPTIONS]. Add examples of input and output to illustrate functionality: [EXAMPLES]. Finally, list any dependencies or requirements that users need to install or configure: [DEPENDENCIES]. This documentation will help future users understand and effectively utilize your code.
In this final stage, you will create reports and visualizations based on your analysis results. Effective reporting communicates insights clearly and supports decision-making.
Draft a summary report of findings
Draft a summary report of your data analysis findings based on the following structure. First, outline the main objectives of the analysis: [OBJECTIVES]. Next, detail the key insights discovered: [INSIGHTS]. Then, provide recommendations based on these findings: [RECOMMENDATIONS]. Additionally, discuss any limitations of the analysis: [LIMITATIONS]. Finally, suggest next steps for further analysis: [NEXT STEPS]. This report should serve as a concise overview of your work.
Create visualizations for key insights
Create visualizations based on the following key insights from your data analysis: [INSIGHTS]. Specify the types of visualizations to create, such as [VISUALIZATION TYPES], and the libraries to use, like [LIBRARIES]. Include any specific design elements you want to incorporate, such as [DESIGN ELEMENTS], and provide a brief explanation of each visualization's purpose, detailing how it contributes to understanding the insights.
Compile a presentation of results
Prepare a presentation to communicate your analysis results. Specify the audience for the presentation as [AUDIENCE], outline the key messages to convey as [KEY MESSAGES], and detail the structure of the presentation using [STRUCTURE]. Additionally, list any visual aids to include, such as [VISUAL AIDS], and indicate the expected duration of the presentation as [DURATION]. This comprehensive approach will ensure effective sharing of your findings.
Automate report generation
Write a Python script that automates the generation of reports based on the following specifications: 1. Identify the data sources for the report: [DATA SOURCES]. 2. Specify the desired report format: [REPORT FORMAT]. 3. List the libraries to be used for automation: [LIBRARIES]. 4. Define the schedule for report generation: [SCHEDULE]. 5. Ensure the script includes a confirmation message that indicates successful report generation. This automation will streamline the reporting process and enhance efficiency.
Share results with stakeholders
Draft a communication to share your results with stakeholders. Include the key findings to highlight: [KEY FINDINGS], the format for sharing: [FORMAT], and any follow-up actions required: [FOLLOW-UP ACTIONS]. Additionally, specify the timeline for sharing: [TIMELINE] and include a call to action for stakeholders: [CALL TO ACTION]. Ensure the message is clear and engaging to effectively convey your insights.
Popular libraries include Pandas for data manipulation, NumPy for numerical operations, Matplotlib and Seaborn for visualizations, and Scikit-learn for machine learning. Each library serves specific purposes and can be combined for comprehensive data analysis.
To optimize Python scripts, focus on efficient data structures, utilize vectorized operations with libraries like NumPy, avoid unnecessary loops, and implement caching for repeated calculations. Profiling tools can help identify bottlenecks.
Common pitfalls include not validating data inputs, hardcoding values, neglecting error handling, and failing to document code. Addressing these issues can improve the reliability and maintainability of your scripts.
Effective visualizations should clearly convey insights, use appropriate chart types, maintain simplicity, and include labels and legends. Testing visualizations with your target audience can also provide valuable feedback.
Tools like Jupyter Notebooks, ReportLab, and Python libraries such as Matplotlib and Pandas can automate report generation. Using templates and scheduling scripts can further enhance efficiency in producing reports.
AI Prompts for DeepSeek for Data Analysis
Data analysts often struggle with efficiently extracting insights from large datasets.
See promptsAI Prompts for Data Analysis
Data analysts often face challenges in extracting insights from complex datasets, leading to time-consuming processes and potential errors.
See promptsAI Prompts for Market Data Analysis
Analysts, investors, and business strategists often struggle with the overwhelming volume of market data and trends, which can lead to missed opportunities or poor decision-making.
See prompts