Skip to main content
Data AnalysisBeginnerFree to access

Pandas Sales Analysis & Reproducible Report

Clean a tiny sales dataset, calculate product revenue and communicate one clearly supported business observation.

Download free Markdown guideNo email, account or payment required · .md text format

What you will build

Learn data cleaning, vectorized operations and reproducible KPI calculations with Pandas.

Before you begin

  • Python 3 and pip
  • Pandas DataFrame basics

Local setup instructions

  1. Create a virtual environment and install pandas.
  2. Save the starter as sales.py and run python sales.py.
  3. Use anonymized or synthetic practice data only; no client or student records.

Starter code

sales.py

This is a working starting example, not the finished project. Follow the setup above and complete each milestone to build your own solution.

import pandas as pd

records = [
    {"product": "Notebook", "units": 2, "price": 150},
    {"product": "Pen", "units": 5, "price": 40},
    {"product": "Notebook", "units": 1, "price": 150},
]
df = pd.DataFrame(records)
df["revenue"] = df["units"] * df["price"]
summary = (
    df.groupby("product", as_index=False)
      .agg(units=("units", "sum"), revenue=("revenue", "sum"))
      .sort_values("revenue", ascending=False)
)
print(summary.to_string(index=False))

Project build milestones

  1. Inspect missing values and duplicated rows before calculating totals.
  2. Create a line total as units multiplied by price.
  3. Group by product and compare revenue, quantity and order counts.
  4. Add a Matplotlib visualization with an informative title and labeled axes.
  5. Write a short interpretation that distinguishes evidence from speculation.

Completion checklist

Use these checks to self-review the finished project.

  • Revenue calculations use numeric columns.
  • Missing inputs are handled or visibly reported.
  • A product appears once in grouped output.
  • The summary can be reproduced by another learner from the script.

Optional challenges

  • Read data from a CSV file and write a data-quality report.
  • Compare month-over-month KPIs using a documented date column.