The Whole Analysis

Load, clean, join, summarise, report -- in one function, from files.

Every step this course has covered

Read the files, fix the types, join on the key, group, round, and return something a reader can use. Each of those was a unit.

import pandas as pd

# people.csv: id,team | scores.csv: id,score
# read -> to_numeric -> merge -> groupby -> round -> report
print("the pipeline is the course")

Check between the steps

Row counts after the join, missing counts after the clean. The checks are what make the final number something you would defend.

import pandas as pd

df = pd.DataFrame({"score": ["90", "n/a"]})
clean = pd.to_numeric(df["score"], errors="coerce")
print(int(clean.isna().sum()), "dropped of", len(df))

Exercise

Try It Yourself

Two files are supplied. people.csv has id and team; scores.csv has id and score, where some scores are n/a. Write report(people_path, scores_path) returning (team, mean) for the highest-scoring team, ignoring rows with no score, with the mean to one decimal place.

Press Run to see output

Check Your Understanding