Secondary education, pupils

Source: worldbank.org, 03.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Albania Albania 216,158 -4.97% 55
Andorra Andorra 5,063 +3.5% 80
United Arab Emirates United Arab Emirates 860,281 +27.3% 34
Armenia Armenia 274,915 +0.928% 51
Azerbaijan Azerbaijan 1,066,209 +3.48% 29
Burkina Faso Burkina Faso 1,185,480 -5.18% 26
Bangladesh Bangladesh 15,661,732 -2.54% 4
Bahrain Bahrain 110,478 -0.17% 60
Bahamas Bahamas 29,409 +18.8% 72
Bosnia & Herzegovina Bosnia & Herzegovina 226,755 -1.06% 54
Belarus Belarus 725,721 +2.09% 39
Belize Belize 37,444 -5.01% 69
Bermuda Bermuda 3,484 -5.33% 83
Bolivia Bolivia 1,292,286 +1.23% 23
Barbados Barbados 18,515 -2.33% 73
Brunei Brunei 40,924 +0.442% 68
China China 96,322,800 +2.75% 2
Côte d’Ivoire Côte d’Ivoire 3,098,275 +22.8% 14
Cameroon Cameroon 2,007,361 +1.21% 19
Congo - Kinshasa Congo - Kinshasa 7,928,331 +7.88% 7
Comoros Comoros 67,764 -8.05% 63
Cuba Cuba 684,680 -7.55% 40
Curaçao Curaçao 12,675 -13.9% 76
Cayman Islands Cayman Islands 4,036 +3.65% 82
Djibouti Djibouti 69,362 -2.17% 62
Dominica Dominica 4,483 -3.3% 81
Dominican Republic Dominican Republic 856,499 -1.66% 35
Algeria Algeria 5,580,053 +1.44% 8
Ecuador Ecuador 1,822,516 -1.96% 20
Fiji Fiji 113,605 +4.16% 59
Georgia Georgia 302,590 +4.74% 50
Gibraltar Gibraltar 2,429 +3.23% 86
Guatemala Guatemala 1,078,266 +3.32% 28
Guyana Guyana 63,477 +0.422% 64
Hong Kong SAR China Hong Kong SAR China 333,774 -1.53% 49
Honduras Honduras 580,717 +1.19% 42
Indonesia Indonesia 26,883,110 -0.742% 3
India India 134,342,141 -3.42% 1
Jamaica Jamaica 184,800 +0.215% 56
Jordan Jordan 1,007,080 +1.72% 30
Kazakhstan Kazakhstan 2,375,914 +5.44% 18
Kyrgyzstan Kyrgyzstan 840,456 +3.38% 36
Cambodia Cambodia 1,132,622 +3.53% 27
Kiribati Kiribati 16,945 +11.5% 74
Laos Laos 568,402 -3.76% 43
Lebanon Lebanon 405,438 -1.16% 48
St. Lucia St. Lucia 10,805 -0.616% 77
Macao SAR China Macao SAR China 30,274 +4.53% 71
Morocco Morocco 3,434,273 +5.85% 12
Monaco Monaco 3,478 +1.84% 84
Moldova Moldova 227,896 -0.743% 53
Maldives Maldives 33,002 +13.6% 70
Mali Mali 1,305,140 +26.3% 22
Montenegro Montenegro 56,561 +0.396% 67
Mongolia Mongolia 412,070 +8.6% 47
Malaysia Malaysia 2,629,154 -0.169% 17
Niger Niger 910,184 +15.7% 32
Nicaragua Nicaragua 463,660 +5.92% 45
Nepal Nepal 3,695,560 +5.2% 11
Nauru Nauru 1,438 +2.64% 88
Oman Oman 513,406 +4.91% 44
Peru Peru 3,209,642 +7.08% 13
Philippines Philippines 12,594,216 +0.152% 5
Palau Palau 1,398 +10.2% 89
Puerto Rico Puerto Rico 236,258 +7.92% 52
Paraguay Paraguay 581,143 -2.64% 41
Palestinian Territories Palestinian Territories 868,232 +1.6% 33
Qatar Qatar 144,410 +7.18% 57
Russia Russia 10,798,220 +1.48% 6
Rwanda Rwanda 819,262 +2.35% 37
Senegal Senegal 1,283,240 -0.224% 24
El Salvador El Salvador 442,494 -0.454% 46
San Marino San Marino 1,715 -1.15% 87
Somalia Somalia 115,828 -11.1% 58
Suriname Suriname 58,269 +15.4% 65
Seychelles Seychelles 7,861 -2.2% 79
Syria Syria 1,353,625 +2.46% 21
Turks & Caicos Islands Turks & Caicos Islands 2,846 +4.9% 85
Chad Chad 750,180 +13% 38
Togo Togo 915,214 +7.37% 31
Thailand Thailand 5,139,185 +6.43% 9
Tajikistan Tajikistan 1,257,135 +1.53% 25
Tonga Tonga 15,981 +2.02% 75
Trinidad & Tobago Trinidad & Tobago 88,408 -0.928% 61
Tuvalu Tuvalu 1,252 -3.99% 90
Ukraine Ukraine 2,645,164 +1.1% 16
Uzbekistan Uzbekistan 4,112,120 +2.22% 10
St. Vincent & Grenadines St. Vincent & Grenadines 9,707 -0.828% 78
Venezuela Venezuela 2,695,688 +12.7% 15
Vanuatu Vanuatu 58,028 +62.1% 66

                    
# 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.SEC.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.SEC.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))