A population data dashboard — world trends, continent breakdowns, fastest-growing nations, and country comparisons from a free CSV dataset.
Our World in Data provides a free global population CSV covering 1800 to present.
import pandas as pd
import matplotlib.pyplot as plt
# Download from:
# https://ourworldindata.org/population-growth
# Click "Download" -> "Full data" -> population.csv
df = pd.read_csv('population.csv')
print(df.columns.tolist())
# ['Entity', 'Code', 'Year', 'Population (historical)']
# Rename for convenience
df.columns = ['Country','Code','Year','Population']
df = df[df['Year'] >= 1950].copy()
print(df[df['Country'] == 'India'].tail(5))
Filter to the top nations and plot their population growth since 1950.
countries = ['India','China','United States','Indonesia','Pakistan','Brazil']
subset = df[df['Country'].isin(countries)]
fig, ax = plt.subplots(figsize=(11, 6))
COLORS = ['#e74c3c','#f59e0b','#3b82f6','#22c55e','#a855f7','#ec4899']
for i, country in enumerate(countries):
cdf = subset[subset['Country'] == country]
ax.plot(cdf['Year'], cdf['Population'] / 1e9, label=country,
linewidth=2.5, color=COLORS[i])
ax.set_title('World Population — Major Countries (1950–2023)', fontsize=14)
ax.set_xlabel('Year')
ax.set_ylabel('Population (billions)')
ax.legend(loc='upper left')
ax.grid(alpha=0.2)
plt.tight_layout()
plt.savefig('population_trends.png', dpi=120)
plt.show()
Calculate growth rate and identify which nations are growing fastest.
# Countries only (exclude regions/continents by filtering on Code column)
countries_only = df[df['Code'].notna() & (df['Code'] != '')]
pop_2000 = countries_only[countries_only['Year'] == 2000].set_index('Country')['Population']
pop_2023 = countries_only[countries_only['Year'] == 2023].set_index('Country')['Population']
growth = ((pop_2023 - pop_2000) / pop_2000 * 100).dropna()
growth = growth[growth > 0].sort_values(ascending=False)
top10 = growth.head(10)
print("Fastest-growing countries 2000-2023 (%):")
print(top10.round(1))
top10.sort_values().plot(kind='barh', figsize=(8,5), color='#22c55e')
plt.title('Top 10 Fastest-Growing Countries (2000-2023)')
plt.xlabel('Population Growth (%)')
plt.tight_layout()
plt.savefig('fastest_growing.png', dpi=120)
plt.show()
You transformed a raw 200-year dataset into three publication-ready charts. The growth rate calculation — (new - old) / old * 100 — is one of the most common patterns in data analysis: it works for populations, revenue, users, or any metric over time.
Spotted a bug, broken code, or something that doesn't look right? Tell us what's off and we'll fix it.