Olympics Data Analysis
Goal
Use Olympics medals/athletes data to:
- Rank countries by medals
- See trends over years
- Identify top sports
Analysis pipeline
flowchart LR A["Raw results"] --> B["Count
(medals per country)"] B --> C["Rank
(sort_values, top 10)"] C --> D["Visualize
(bar chart)"] D --> E["Trend
(medals by year)"]
Step 1: Load
Load
import pandas as pd
df = pd.read_csv("data/olympics.csv")
print(df.head())Load
import pandas as pd
df = pd.read_csv("data/olympics.csv")
print(df.head())Step 2: Basic counts
Medal counts
medals = df.groupby("country").size().sort_values(ascending=False).head(10)
print(medals)Medal counts
medals = df.groupby("country").size().sort_values(ascending=False).head(10)
print(medals)Step 3: Plot top countries
Top countries
import matplotlib.pyplot as plt
plt.figure(figsize=(10, 4))
plt.bar(medals.index, medals.values)
plt.title("Top 10 countries by medals")
plt.xticks(rotation=25)
plt.tight_layout()
plt.show()Top countries
import matplotlib.pyplot as plt
plt.figure(figsize=(10, 4))
plt.bar(medals.index, medals.values)
plt.title("Top 10 countries by medals")
plt.xticks(rotation=25)
plt.tight_layout()
plt.show()Visualize it
Deliverable
- Top 10 countries
- Change over years
- Sports that contribute most
🧪 Try It Yourself
Exercise 1 – Medal counts per country
Exercise 2 – Top N ranking
Exercise 3 – Medals by year (trend)
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
