---
name: python-pandas-data-analyzer
description: "Runnable Pandas code that cleans, reshapes, and analyses a described dataset, with the missing-value handling and optional plot already written. Use when an analyst needs Pandas code to clean and analyse a dataset they can describe by its columns and goal. Do not use for SQL queries or choosing which statistical test to use. Related topics: data, python, coding."
---

# Python Pandas Data Analyzer

Runnable Pandas code that cleans, reshapes, and analyses a described dataset, with the missing-value handling and optional plot already written.

## When to use

Use this skill when an analyst needs Pandas code to clean and analyse a dataset they can describe by its columns and goal. Do not use it for SQL queries or choosing which statistical test to use.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Write the load step with checks for dtypes, nulls, and duplicates, and print the findings.
3. Add cleaning for missing values and dates, each with a comment on the assumption it makes.
4. Implement the requested operations with vectorised Pandas, done when the final DataFrame answers the stated goal.
5. Add the plot if requested, with labelled axes and a title.
6. Include a small sample dataset and list any column-name or dtype assumptions.

## Inputs

- **Dataset (columns and data types)** (longer free text)
- **Goal of the analysis** (longer free text)
- **Operations to include** (choose any: GroupBy, Merge or join, Handle missing values, Pivot tables, Date parsing)
- **Add a Matplotlib or Seaborn plot** (choose one: Yes, No)
- **Output format** (choose one: Python script, Jupyter notebook cells)

## Output

One code block in the chosen format (script or notebook cells) with comments and sample data, then a short list of assumptions.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### Pandas Analysis Script

Write Pandas code for the dataset and goal below.

- Dataset (columns and data types): {{Dataset (columns and data types)}}
- Goal of the analysis: {{Goal of the analysis}}
- Operations to include: {{Operations to include}}
- Add a Matplotlib or Seaborn plot: {{Add a Matplotlib or Seaborn plot}}
- Output format: {{Output format}}

Start by loading the data and checking dtypes, nulls, and duplicates, then clean before analysing and say what each cleaning step assumes. Use vectorised operations and method chaining rather than loops. Name intermediate DataFrames clearly and comment the why of each step, not the what. Make the result print a small, readable table. If a plot is requested, label axes and title it. Use placeholder file paths and a tiny made-up sample so the code runs as written, and note any assumption about column names or types.

## Pitfalls

- Using loops or apply where a vectorised operation is faster and clearer.
- Filling missing values silently, which changes the result without the reader knowing.
- Merging without checking key uniqueness, which duplicates rows and inflates totals.
