Pandas & Data Analysis·Pandas from first Series to analysis project

Analysis project

Answer a real question end to end with a reproducible notebook.

Beginner 24 min read Lesson 10 of 300 Challenge included
What you will be able to do
  • Write the question before touching the data.
  • Keep raw data immutable.
  • Show the cleaning decisions.
  • End with limitations and next questions.

In plain English

A good analysis states the question, describes the data, cleans it, answers the question and admits the limits. Save the notebook so another person can rerun it from the raw file.

analysis.pyPython
import pandas as pd

raw = pd.read_csv('lessons.csv', parse_dates=['published_at'])
clean = (
    raw.drop_duplicates()
    .dropna(subset=['course', 'minutes'])
    .assign(month=lambda d: d['published_at'].dt.to_period('M'))
)

answer = (
    clean.groupby(['month', 'course'])['minutes']
    .agg(['size', 'mean'])
    .reset_index()
    .sort_values('mean', ascending=False)
)

print(clean.shape, '->', answer.head(10))
Your turn

Report dropped rows

Medium

Print how many rows were dropped by dropna.

PYTHON · starter
print(len(raw))
Check your understanding before moving on.
Knowledge checkQuestion 1

What should every analysis report include?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Lesson 10 of 300 · 0% of course