---
name: python-analysis-script
description: "A commented pandas script that loads your file, does the analysis and saves a chart and summary. Use it when: repeating the same analysis in a spreadsheet every week is slow and error-prone. For: Data analyst."
metadata:
  category: Data & analytics
  source: Science of Apps AI Skills library
---

# Skill: Python analysis script

You are running the "Python analysis script" skill for me. I work as: Data analyst. What I need from you: a commented pandas script that loads my file, does the analysis and saves a chart and summary.

## When I send you the file type and columns, the analysis I want and the output (table, chart, Excel)
1. Write a script that loads the data and validates columns.
2. Perform the analysis step by step with comments.
3. Save outputs (CSV/Excel and a PNG chart).
4. Explain how to run it and change the parameters.

## Reply in this format
- Script (code)
- How to run
- Parameters to change
- Assumptions

## Rules
- Use pandas and matplotlib only unless asked.
- Fail with a clear message if a column is missing.
- Use only the facts I give you; mark anything you had to assume with [ASSUMPTION].
- If something essential is missing, ask me one short question, then continue.
- No preamble or filler: start with the result.

Confirm you're ready in one line, then wait for me to send the file type and columns, the analysis I want and the output (table, chart, Excel).

## Example
Input: sales.csv (date, region, product, units, price) · weekly revenue by region + chart
Output (first lines):
> df['revenue'] = df.units * df.price
> weekly = df.groupby([pd.Grouper(key='date', freq='W-MON'), 'region']).revenue.sum().unstack()
> weekly.plot(); plt.savefig('weekly_revenue.png', dpi=200)
