One idea
A join is not done when the code runs. It is done when the row counts, missing matches, and chart shape make sense.
Why joins fail
Most data projects have more than one table. A college events dataset may have registrations in one CSV and college details in another JSON file.
The risky part is the join key. If one file has college_id as 101 and another has "101 ", pandas may not match them until you clean type and spaces.
Pick the join
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done
Join and check
This example joins event registrations with college details. It keeps every registration, then checks which colleges did not match.
import pandas as pd
regs = pd.read_csv("data/clean_registrations.csv")
colleges = pd.read_json("data/clean_colleges.json")
# Clean join keys again before merge
regs["college_id"] = regs["college_id"].astype("str").str.strip()
colleges["college_id"] = colleges["college_id"].astype("str").str.strip()
print("regs rows:", len(regs))
print("college rows:", len(colleges))
merged = regs.merge(
colleges,
on="college_id",
how="left",
indicator=True
)
print("merged rows:", len(merged))
print(merged["_merge"].value_counts())
unmatched = merged[merged["_merge"] == "left_only"]
print(unmatched[["registration_id", "college_id"]].head())
merged.to_csv("output/merged_registrations.csv", index=False)Avoid silent duplicates
If the right table has the same college_id many times, one registration can turn into many rows. Your total count will grow and your chart may look impressive but wrong.
Before merging, check whether the key should be unique. If it should be unique, remove or fix duplicates first.
duplicate_colleges = colleges[colleges.duplicated("college_id", keep=False)]
print(duplicate_colleges.sort_values("college_id").head())Use AI carefully
You can ask ChatGPT, Gemini, or Claude to suggest the join key and join type. Paste column names and two sample rows, not private student data.
Check the answer yourself. Ask: Which table is the main table? Can the key repeat? What rows would be lost with an inner join?
Chart the result
Quick charts are checks, not final dashboard work. Use them to catch odd joins, missing matches, and strange category counts.
Pandas plotting uses Matplotlib. For missing data, bar plots fill missing values with 0, while scatter plots and histograms drop missing values. Use fillna or dropna first if that is not what you want.
import matplotlib.pyplot as plt
# Count registrations by city after the join
city_counts = (
merged["city"]
.fillna("Unknown")
.value_counts()
.head(10)
)
city_counts.plot(kind="bar", title="Top cities by registrations")
plt.xlabel("City")
plt.ylabel("Registrations")
plt.tight_layout()
plt.savefig("output/top_cities.png")
plt.close()
# Check fee vs attendance only where both are present
plot_data = merged.dropna(subset=["fee_rupees", "attendance_percent"])
plot_data.plot(
kind="scatter",
x="fee_rupees",
y="attendance_percent",
title="Fee vs attendance"
)
plt.tight_layout()
plt.savefig("output/fee_vs_attendance.png")
plt.close()Do this now
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done