The prompt
Score 10 of 10, Excellent
Use it when You redraw the same chart from a spreadsheet or CSV every time the data changes, and want a Python script that draws it the same way each time.
- {{audience}}
- {{destination}}
- {{output_format}}
- {{data_file}}
- {{columns}}
- {{chart_wanted}}
- {{setup}}
- {{sample_rows}}
Full prompt and why it works
Prompt
# Role You write short Python scripts with pandas and matplotlib that turn a spreadsheet or CSV file into one clear, accurate chart. # Goal Write a script that reads my file and draws the chart described below, for {{audience}}, saved as an image I can put in {{destination}}, so that the chart can be redrawn the same way each time the data changes. # Success criteria - It reads the columns by the exact names given below and never types in data values. - A reader can understand the chart without me: a title, axis labels with units, font sizes readable at the final size, and a legend only when there is more than one series. - Bar and column charts start at zero, and bars are sorted by value unless the categories have a natural order such as months. - Dates are parsed as dates, and numbers show thousands separators. - It runs with python chart.py after I change only the paths at the top. # Constraints - Use only pandas, matplotlib and the standard library, plus openpyxl if the file is Excel. - Do not drop, fill or change rows silently. If rows are excluded (blanks, dates that cannot be read), print how many and why. - Use one color for a single series, and a colorblind-safe palette (for example Okabe-Ito) for several. Avoid 3D effects, shadows and pie charts with more than five slices. - Avoid clever one-liners; the next person to change it may not be a programmer. # Output 1. The script in one code block, with INPUT_PATH, OUTPUT_PATH, the column names and the chart size as constants at the top, and a comment above each step. 2. It saves to {{output_format}} with dpi=200 and bbox_inches="tight", and prints the summarized table it plotted, so I can compare a few values with my spreadsheet. 3. Below the script, up to six lines on how to install the packages and run it. For example, a title that works reads: "Monthly orders by region, January to June". That example shows the form only; write the title from my description. # Stop rules If the sample rows do not match the column names I gave, or a column mixes formats (dates written two ways, numbers stored as text with currency signs), say so before the script and handle it explicitly in the code. If the chart I asked for would mislead or be hard to read, such as a line chart across unordered categories, say so in one line and suggest a better type, then write the one I asked for. # Context File type and path: {{data_file}} Columns and what they hold: {{columns}} The chart (type, what goes on each axis, grouping, and whether values are summed or averaged): {{chart_wanted}} Python version and what I can install: {{setup}} Sample rows, including the header: """ {{sample_rows}} """
Variables
- {{audience}}
- Who will see the chart, for example "the monthly operations review".
- {{destination}}
- Where it goes and at what size, for example "a 16:9 slide, half width" or "a printed A4 report".
- {{output_format}}
- PNG for slides and documents, or SVG if it will be edited or shown on the web.
- {{data_file}}
- For example "CSV, exports/orders.csv" or "Excel, Sales.xlsx, sheet Data".
- {{columns}}
- Each column you will use and what it holds, for example "order_date (date), region (text), amount (number, USD)".
- {{chart_wanted}}
- For example "bar chart of total amount by region, sorted" or "line chart of weekly orders, one line per region".
- {{setup}}
- For example "Python 3.12 on Windows, pandas and matplotlib installed".
- {{sample_rows}}
- The header and 10 to 20 rows of the file, including any odd ones. Mask personal data.
Why it works
- What to avoid. The script reads data only from your file and prints any rows it leaves out, so no chart is drawn from typed-in or silently dropped values.
- What good looks like. Zero-based bars, sorted categories, labeled axes and a colorblind-safe palette are spelled out, which is what keeps a chart readable once it is pasted into a slide.
- If unsure. Mismatched column names and mixed formats are reported before the code and handled in it, instead of becoming a chart that is quietly wrong.