Primary education, pupils

Source: worldbank.org, 03.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Albania Albania 146,962 -4.66% 72
Andorra Andorra 4,271 +4.2% 101
United Arab Emirates United Arab Emirates 554,644 +20% 54
Armenia Armenia 156,224 +0.272% 70
Azerbaijan Azerbaijan 627,013 -1.85% 51
Burkina Faso Burkina Faso 2,835,544 -10.7% 28
Bangladesh Bangladesh 16,252,802 -5.3% 5
Bahrain Bahrain 117,665 +2.3% 77
Bahamas Bahamas 23,311 -20.7% 91
Bosnia & Herzegovina Bosnia & Herzegovina 141,518 -1.64% 73
Belarus Belarus 451,993 -0.0752% 58
Belize Belize 44,727 -1.95% 85
Bermuda Bermuda 3,377 +0.208% 104
Bolivia Bolivia 1,394,417 -0.705% 39
Barbados Barbados 17,209 -3.29% 93
Brunei Brunei 38,604 -1.21% 88
China China 107,539,968 -0.444% 2
Côte d’Ivoire Côte d’Ivoire 4,632,737 +8.94% 17
Cameroon Cameroon 5,155,547 +4.27% 14
Congo - Kinshasa Congo - Kinshasa 21,145,524 +4.84% 4
Congo - Brazzaville Congo - Brazzaville 880,625 +12.4% 45
Comoros Comoros 120,186 +14.4% 76
Cuba Cuba 726,675 -3.01% 49
Curaçao Curaçao 11,693 -14.2% 97
Cayman Islands Cayman Islands 4,575 +1.53% 100
Djibouti Djibouti 69,705 -3.13% 82
Dominica Dominica 5,766 -3.63% 99
Dominican Republic Dominican Republic 1,165,161 +0.864% 41
Algeria Algeria 5,187,616 +2.71% 13
Ecuador Ecuador 1,773,277 -3.92% 35
Egypt Egypt 13,821,921 +0.0266% 7
Ethiopia Ethiopia 15,545,095 +0.159% 6
Fiji Fiji 115,485 -0.115% 78
Georgia Georgia 345,099 -0.307% 63
Gibraltar Gibraltar 2,824 -2.86% 105
Gambia Gambia 428,053 +3.28% 60
Guatemala Guatemala 2,413,805 -0.0472% 30
Guyana Guyana 91,199 -0.219% 80
Hong Kong SAR China Hong Kong SAR China 337,549 -4.37% 64
Honduras Honduras 1,074,043 +0.703% 43
Indonesia Indonesia 28,619,329 -0.73% 3
India India 131,298,001 -0.0381% 1
Jamaica Jamaica 195,202 -8.45% 68
Jordan Jordan 1,105,189 -0.774% 42
Kazakhstan Kazakhstan 1,573,512 +0.947% 37
Kyrgyzstan Kyrgyzstan 607,542 +3.78% 53
Cambodia Cambodia 2,198,283 +1.55% 32
Kiribati Kiribati 17,777 -4.02% 92
Laos Laos 741,976 +0.451% 48
Lebanon Lebanon 524,141 +0.836% 55
St. Lucia St. Lucia 14,936 -2.94% 95
Lesotho Lesotho 312,005 -1.18% 65
Macao SAR China Macao SAR China 37,854 +2.89% 89
Morocco Morocco 4,683,013 +0.161% 16
Monaco Monaco 2,024 +3.48% 107
Moldova Moldova 137,227 -0.518% 74
Madagascar Madagascar 5,113,497 -0.225% 15
Maldives Maldives 45,617 +2.4% 84
Mali Mali 2,972,650 +8.39% 25
Montenegro Montenegro 38,834 +1.76% 87
Mongolia Mongolia 381,720 +2.48% 61
Mozambique Mozambique 7,746,890 +1.19% 11
Mauritania Mauritania 861,768 +31.7% 47
Mauritius Mauritius 89,001 +5.79% 81
Malawi Malawi 4,623,698 +7.85% 18
Malaysia Malaysia 3,092,312 +2.24% 23
Niger Niger 3,022,704 +3.89% 24
Nicaragua Nicaragua 880,080 +0.909% 46
Nepal Nepal 3,610,603 +3.6% 21
Nauru Nauru 2,041 +7.65% 106
Oman Oman 348,024 +5.25% 62
Panama Panama 443,447 -5.68% 59
Peru Peru 3,775,989 -1.13% 20
Philippines Philippines 12,953,380 +1.77% 8
Palau Palau 1,401 +7.6% 110
Puerto Rico Puerto Rico 150,261 -27.9% 71
Paraguay Paraguay 718,847 +0.543% 50
Palestinian Territories Palestinian Territories 514,700 +2.15% 56
Qatar Qatar 173,438 +4.01% 69
Russia Russia 7,554,896 -1.64% 12
Rwanda Rwanda 2,838,343 +3.49% 27
Senegal Senegal 2,340,219 +0.814% 31
Solomon Islands Solomon Islands 95,872 -4.57% 79
Sierra Leone Sierra Leone 2,017,170 -1.52% 34
El Salvador El Salvador 609,862 +1.46% 52
San Marino San Marino 1,462 -2.73% 108
Somalia Somalia 464,607 +85.5% 57
Suriname Suriname 42,524 -32.5% 86
Eswatini Eswatini 222,351 -5.78% 67
Sint Maarten Sint Maarten 3,913 +6.42% 102
Seychelles Seychelles 9,598 +0.629% 98
Syria Syria 2,172,256 +0.0821% 33
Turks & Caicos Islands Turks & Caicos Islands 3,511 +3.23% 103
Chad Chad 2,955,477 +4.33% 26
Togo Togo 1,664,472 -0.479% 36
Thailand Thailand 4,611,695 -2.4% 19
Tajikistan Tajikistan 994,877 +1.71% 44
Timor-Leste Timor-Leste 227,656 +2.28% 66
Tonga Tonga 16,114 -2.61% 94
Trinidad & Tobago Trinidad & Tobago 128,993 -0.536% 75
Tunisia Tunisia 1,337,527 +1.24% 40
Tuvalu Tuvalu 1,432 +3.1% 109
Tanzania Tanzania 11,428,969 +8.29% 9
Ukraine Ukraine 1,524,174 -10.1% 38
Uzbekistan Uzbekistan 2,543,859 +3.24% 29
St. Vincent & Grenadines St. Vincent & Grenadines 12,163 -2.31% 96
Venezuela Venezuela 3,540,946 +6.89% 22
Vietnam Vietnam 9,192,690 -0.0946% 10
Vanuatu Vanuatu 55,233 -2.05% 83
Samoa Samoa 35,003 -0.937% 90

                    
# Install missing packages
import sys
import subprocess

def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])

# Required packages
for package in ['wbdata', 'country_converter']:
try:
__import__(package)
except ImportError:
install(package)

# Import libraries
import wbdata
import country_converter as coco
from datetime import datetime

# Define World Bank indicator code
dataset_code = 'SE.PRM.ENRL'

# Download data from World Bank API
data = wbdata.get_dataframe({dataset_code: 'value'},
date=(datetime(1960, 1, 1), datetime.today()),
parse_dates=True,
keep_levels=True).reset_index()

# Extract year
data['year'] = data['date'].dt.year

# Convert country names to ISO codes using country_converter
cc = coco.CountryConverter()
data['iso2c'] = cc.convert(names=data['country'], to='ISO2', not_found=None)
data['iso3c'] = cc.convert(names=data['country'], to='ISO3', not_found=None)

# Filter out rows where ISO codes could not be matched — likely not real countries
data = data[data['iso2c'].notna() & data['iso3c'].notna()]

# Sort for calculation
data = data.sort_values(['iso3c', 'year'])

# Calculate YoY absolute and percent change
data['value_change'] = data.groupby('iso3c')['value'].diff()
data['value_change_percent'] = data.groupby('iso3c')['value'].pct_change() * 100

# Calculate ranks (higher GDP per capita = better rank)
data['rank'] = data.groupby('year')['value'].rank(ascending=False, method='dense')

# Calculate rank change from previous year
data['rank_change'] = data.groupby('iso3c')['rank'].diff()

# Select desired columns
final_df = data[['country', 'iso2c', 'iso3c', 'year', 'value',
'value_change', 'value_change_percent', 'rank', 'rank_change']].copy()

# Optional: Add labels as metadata (could be useful for export or UI)
column_labels = {
'country': 'Country name',
'iso2c': 'ISO 2-letter country code',
'iso3c': 'ISO 3-letter country code',
'year': 'Year',
'value': 'GDP per capita (current US$)',
'value_change': 'Year-over-Year change in value',
'value_change_percent': 'Year-over-Year percent change in value',
'rank': 'Country rank by GDP per capita (higher = richer)',
'rank_change': 'Change in rank from previous year'
}

# Display first few rows
print(final_df.head(10))

# Optional: Save to CSV
#final_df.to_csv("gdp_per_capita_cleaned.csv", index=False)
                    
                
                    
# Check and install required packages
required_packages <- c("WDI", "countrycode", "dplyr")

for (pkg in required_packages) {
  if (!requireNamespace(pkg, quietly = TRUE)) {
    install.packages(pkg)
  }
}

# Load the necessary libraries
library(WDI)
library(dplyr)
library(countrycode)

# Define the dataset code (World Bank indicator code)
dataset_code <- 'SE.PRM.ENRL'

# Download data using WDI package
dat <- WDI(indicator = dataset_code)

# Filter only countries using 'is_country' from countrycode
# This uses iso2c to identify whether the entry is a recognized country
dat <- dat %>%
  filter(countrycode(iso2c, origin = 'iso2c', destination = 'country.name', warn = FALSE) %in%
           countrycode::codelist$country.name.en)

# Ensure dataset is ordered by country and year
dat <- dat %>%
  arrange(iso3c, year)

# Rename the dataset_code column to "value" for easier manipulation
dat <- dat %>%
  rename(value = !!dataset_code)

# Calculate year-over-year (YoY) change and percentage change
dat <- dat %>%
  group_by(iso3c) %>%
  mutate(
    value_change = value - lag(value),                              # Absolute change from previous year
    value_change_percent = 100 * (value - lag(value)) / lag(value) # Percent change from previous year
  ) %>%
  ungroup()

# Calculate rank by year (higher value => higher rank)
dat <- dat %>%
  group_by(year) %>%
  mutate(rank = dense_rank(desc(value))) %>% # Rank countries by descending value
  ungroup()

# Calculate rank change (positive = moved up, negative = moved down)
dat <- dat %>%
  group_by(iso3c) %>%
  mutate(rank_change = rank - lag(rank)) %>% # Change in rank compared to previous year
  ungroup()

# Select and reorder final columns
final_data <- dat %>%
  select(
    country,
    iso2c,
    iso3c,
    year,
    value,
    value_change,
    value_change_percent,
    rank,
    rank_change
  )

# Add labels (variable descriptions)
attr(final_data$country, "label") <- "Country name"
attr(final_data$iso2c, "label") <- "ISO 2-letter country code"
attr(final_data$iso3c, "label") <- "ISO 3-letter country code"
attr(final_data$year, "label") <- "Year"
attr(final_data$value, "label") <- "GDP per capita (current US$)"
attr(final_data$value_change, "label") <- "Year-over-Year change in value"
attr(final_data$value_change_percent, "label") <- "Year-over-Year percent change in value"
attr(final_data$rank, "label") <- "Country rank by GDP per capita (higher = richer)"
attr(final_data$rank_change, "label") <- "Change in rank from previous year"

# Print the first few rows of the final dataset
print(head(final_data, 10))