EN VI

A Python Data Analysis Portfolio Project, Step by Step

By ··9 min read

Short answer

A good Python portfolio project answers one business question in five steps. Load the data, check it for missing values and duplicates, clean it and say what you removed, calculate the numbers, and explain the result in three sentences. The explanation and the cleaning log show more skill than a long list of charts.

Many beginner portfolios show ten charts and no conclusion. On a table with a few hundred thousand orders, a reader wants one answer and a reason to trust it. To build that, we run a small project from the question to the explanation. We use 13 orders here so every number fits on the page. With your own file, the steps stay the same.

Step 1: write the question first

A project without a question turns into a tour of the data. Ours is simple. Did paid revenue fall from September to October, and which customers drive it? Writing the question first also tells us which columns we need, so we do not clean the rest.

Step 2: load the data and check it before you calculate

We read the file, then count the shape, the missing amounts and the repeated order IDs. The raw total is 159,000,000. We keep that number, because it is the figure a careless script would report.

import io
import pandas as pd

raw = io.StringIO("""order_id,customer,total_amount,status,order_date
2001,Ruby Hoang,15000000,paid,2026-09-02
2002,Ethan Vu,8000000,paid,2026-09-05
2003,Ruby Hoang,12000000,cancelled,2026-09-09
2004,Kevin Do,20000000,paid,2026-09-14
2005,Ethan Vu,5000000,paid,2026-09-21
2006,Sophie Ly,18000000,paid,2026-09-28
2007,Kevin Do,9000000,paid,2026-10-03
2008,Ruby Hoang,22000000,paid,2026-10-07
2009,Sophie Ly,,paid,2026-10-11
2010,Ethan Vu,7000000,cancelled,2026-10-15
2011,Kevin Do,16000000,paid,2026-10-20
2011,Kevin Do,16000000,paid,2026-10-20
2012,Ruby Hoang,11000000,paid,2026-10-26
""")
df = pd.read_csv(raw, parse_dates=["order_date"])

print(df.shape)                          # (13, 5)
print(df["total_amount"].isna().sum())   # 1 missing amount
print(df.duplicated("order_id").sum())   # 1 repeated order
print(df["total_amount"].sum())          # 159000000.0

Step 3: clean the data and say what you removed

Three problems sit in the file. Order 2011 appears twice, orders 2003 and 2010 are cancelled, and order 2009 is paid but has no amount. We drop the repeated row, keep only paid orders, and drop the paid order without an amount. The clean total is 124,000,000, which is 35,000,000 lower than the raw total.

clean = df.drop_duplicates("order_id")
print(clean.shape)                                          # (12, 5)
print(round((clean["status"] == "cancelled").mean(), 3))    # 0.167

paid = clean[clean["status"] == "paid"].dropna(subset=["total_amount"])
print(paid.shape, paid["total_amount"].sum())               # (9, 5) 124000000.0

Step 4: calculate the numbers that answer the question

This is a group-and-summarise problem, so we use groupby twice. The first call groups by month, and the second groups by customer. We also compute the change between the two months.

paid = paid.assign(month=paid["order_date"].dt.strftime("%Y-%m"))
monthly = paid.groupby("month")["total_amount"].agg(["count", "sum"])
print(monthly)

by_customer = paid.groupby("customer")["total_amount"].sum().sort_values(ascending=False)
print((by_customer / by_customer.sum()).round(3))

change = monthly["sum"].iloc[1] / monthly["sum"].iloc[0] - 1
print(round(change, 3))                                     # -0.121
MonthPaid ordersPaid revenue
2026-09566000000
2026-10458000000
CustomerPaid revenueShare
Ruby Hoang4800000038.7%
Kevin Do4500000036.3%
Sophie Ly1800000014.5%
Ethan Vu1300000010.5%

Step 5: explain the result in three sentences

The explanation is the part a hiring manager reads first. We state the answer, the driver, and the limit of the data.

  • Paid revenue fell 12% from September (66,000,000 from 5 orders) to October (58,000,000 from 4 orders).
  • Ruby Hoang and Kevin Do bring 75% of paid revenue between them, so a change in either customer moves the total.
  • One paid October order has no amount and is excluded, so October may be understated.

What to publish with the project

  • The notebook, with the question as its first line.
  • A short cleaning log that lists what you removed and why.
  • The three-sentence explanation at the top.
  • A note on what you would check next, for example the missing amount.

If you want a refresher on the reading and grouping steps, they are covered in pandas Basics: Read, Filter and Group Data in Python.

Frequently asked questions

What should a Python portfolio project for a data analyst include?

One clear business question, a check of the data quality, a cleaning log, the calculations and a short written explanation of the result.

How big should a portfolio dataset be?

Large enough that you cannot check it by eye, so a few hundred rows or more. A tiny table can teach the steps, but a reader trusts a project more when the data has real size.

Do I need charts in a Python portfolio project?

One or two charts help when they show the answer, such as the monthly totals. Charts without a stated conclusion add little.

References

Keep learning, step by step.

Each lesson in Learn has a business context, a runnable example and a result check, so you practise this habit on real questions.