School enrollment, tertiary, male (% gross)

Source: worldbank.org, 03.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Angola Angola 10 -13.9% 61
Albania Albania 52.7 +4.21% 12
Andorra Andorra 58.8 +73.7% 8
United Arab Emirates United Arab Emirates 54.3 -0.435% 10
Armenia Armenia 51.7 +0.161% 13
Azerbaijan Azerbaijan 37.3 -0.928% 27
Burundi Burundi 7 -1.06% 63
Burkina Faso Burkina Faso 12.1 +1.3% 56
Bangladesh Bangladesh 25.5 +3.08% 41
Bahrain Bahrain 57.8 -7.54% 9
Bosnia & Herzegovina Bosnia & Herzegovina 34.7 +0.22% 30
Belarus Belarus 62.8 -5.93% 6
Belize Belize 16.2 -4.22% 50
Bermuda Bermuda 13.7 -27.7% 54
Brunei Brunei 31.4 +19.7% 35
Bhutan Bhutan 15.1 -12.5% 53
Botswana Botswana 16.6 -2.03% 49
China China 69.5 +4.18% 4
Côte d’Ivoire Côte d’Ivoire 11.8 +0.778% 57
Cameroon Cameroon 17.3 -3.73% 46
Congo - Brazzaville Congo - Brazzaville 12.4 -15.6% 55
Cuba Cuba 34.2 +23.3% 31
Algeria Algeria 44.1 +12% 20
Egypt Egypt 39.3 +4.49% 24
Fiji Fiji 49.7 -11.1% 17
Georgia Georgia 73.7 +0.705% 3
Ghana Ghana 22.4 +6.61% 44
Guatemala Guatemala 24.1 +35.9% 43
Hong Kong SAR China Hong Kong SAR China 95.7 +2.07% 2
Indonesia Indonesia 40.3 +4.73% 22
India India 33.4 +3.92% 32
Jordan Jordan 26.8 +2.49% 40
Kazakhstan Kazakhstan 51.2 -3.47% 14
Kyrgyzstan Kyrgyzstan 50.4 -2.47% 15
Cambodia Cambodia 16.7 +4.51% 48
Laos Laos 5.31 -60.6% 66
Macao SAR China Macao SAR China 123 +11.9% 1
Morocco Morocco 44 +1.52% 21
Madagascar Madagascar 6.34 +4.07% 64
Montenegro Montenegro 44.2 -7.29% 19
Mongolia Mongolia 49.9 +2.03% 16
Malaysia Malaysia 35.2 +1.11% 29
Nicaragua Nicaragua 24.6 +49.6% 42
Nepal Nepal 15.8 +20.1% 51
Oman Oman 36.3 +0.998% 28
Pakistan Pakistan 11.4 +5.38% 58
Philippines Philippines 37.6 +16.5% 26
Palau Palau 27.9 -22.7% 38
Puerto Rico Puerto Rico 64 -25.6% 5
Palestinian Territories Palestinian Territories 32.2 -6.65% 34
Rwanda Rwanda 10.1 +19.1% 59
Senegal Senegal 17 -0.448% 47
El Salvador El Salvador 27.5 +2.95% 39
San Marino San Marino 53.8 -7.78% 11
Serbia Serbia 59.3 -0.0456% 7
Sint Maarten Sint Maarten 1.32 +16.3% 67
Seychelles Seychelles 10.1 +7.33% 60
Turks & Caicos Islands Turks & Caicos Islands 15.8 +67.1% 52
Thailand Thailand 39.4 +4.82% 23
Tajikistan Tajikistan 33.3 -16.9% 33
Timor-Leste Timor-Leste 29.6 +45.4% 36
Tonga Tonga 37.9 +186% 25
Tunisia Tunisia 28 +0.58% 37
Tanzania Tanzania 5.73 -4.15% 65
Uzbekistan Uzbekistan 45.2 +36.1% 18
British Virgin Islands British Virgin Islands 22.3 -2.88% 45
Samoa Samoa 7.46 -33.6% 62

                    
# 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.TER.ENRR.MA'

# 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.TER.ENRR.MA'

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