Lower secondary completion rate, total (% of relevant age group)

Source: worldbank.org, 03.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Albania Albania 91.7 -5.56% 35
Andorra Andorra 100 +11.3% 10
United Arab Emirates United Arab Emirates 104 +31.9% 7
Armenia Armenia 101 -2.51% 8
Azerbaijan Azerbaijan 87.6 +2.81% 41
Burkina Faso Burkina Faso 27.6 -9.95% 77
Bangladesh Bangladesh 78.2 -5.71% 51
Bahrain Bahrain 95.9 -3.31% 16
Bosnia & Herzegovina Bosnia & Herzegovina 87.8 +0.921% 40
Belarus Belarus 92.8 -0.442% 34
Belize Belize 68.3 +10.7% 59
Bolivia Bolivia 88.4 +7.2% 39
Barbados Barbados 95.5 +9.41% 18
Brunei Brunei 94.4 -9.78% 24
Côte d’Ivoire Côte d’Ivoire 80.4 +39% 48
Cameroon Cameroon 34.7 -1.98% 72
Cuba Cuba 88.5 +0.905% 38
Cayman Islands Cayman Islands 114 +9.82% 4
Dominica Dominica 75.8 -13.1% 53
Dominican Republic Dominican Republic 73 -6.53% 55
Algeria Algeria 84 +10.4% 46
Ecuador Ecuador 90.5 -3.37% 37
Ethiopia Ethiopia 22.2 -25.5% 78
Fiji Fiji 93.3 -5.06% 30
Georgia Georgia 94.7 -3.44% 21
Gibraltar Gibraltar 130 +2.66% 2
Guatemala Guatemala 49.7 -1.82% 66
Honduras Honduras 36.5 -2.91% 70
Indonesia Indonesia 98.6 -3.68% 12
India India 85.5 -5.06% 43
Jamaica Jamaica 85.2 +0.847% 44
Jordan Jordan 93.4 +3.77% 29
Kazakhstan Kazakhstan 94.1 +2.1% 26
Kyrgyzstan Kyrgyzstan 95.1 +1.68% 19
Cambodia Cambodia 61.8 -0.628% 60
Kiribati Kiribati 98.4 +6.66% 13
Laos Laos 54.6 -5.91% 64
Lebanon Lebanon 54.1 +23.8% 65
St. Lucia St. Lucia 85 -2.92% 45
Lesotho Lesotho 41.9 -13.7% 68
Macao SAR China Macao SAR China 92.9 +8.85% 33
Morocco Morocco 74.2 +2.66% 54
Madagascar Madagascar 31.9 -2.64% 74
Maldives Maldives 99.9 +15.6% 11
Mali Mali 28.8 +1.78% 76
Montenegro Montenegro 97 -1.82% 14
Mongolia Mongolia 94.7 -1.26% 23
Mozambique Mozambique 31.7 -24.8% 75
Mauritius Mauritius 121 -4.86% 3
Malaysia Malaysia 87.5 +5.41% 42
Niger Niger 15 -3.31% 79
Nepal Nepal 104 +2.88% 6
Nauru Nauru 79.7 +5.7% 50
Oman Oman 94.7 +5.08% 22
Panama Panama 76.7 -6.99% 52
Peru Peru 93.6 +3.82% 28
Philippines Philippines 93.2 -4.83% 31
Palau Palau 94.9 +3.98% 20
Puerto Rico Puerto Rico 82.7 -8.31% 47
Paraguay Paraguay 72.1 +6.05% 56
Palestinian Territories Palestinian Territories 90.5 -1.8% 36
Rwanda Rwanda 32.3 -16.2% 73
Senegal Senegal 39.3 +1.32% 69
Solomon Islands Solomon Islands 61.4 -12.7% 61
El Salvador El Salvador 69 -0.684% 58
San Marino San Marino 93.7 +0.558% 27
Seychelles Seychelles 93.2 -7.34% 32
Syria Syria 42.4 -1.89% 67
Togo Togo 58.3 -8.01% 63
Thailand Thailand 140 +4.41% 1
Tonga Tonga 95.9 -2.47% 15
Trinidad & Tobago Trinidad & Tobago 71.9 -7.26% 57
Tuvalu Tuvalu 80.2 -5.91% 49
Tanzania Tanzania 35.4 -0.235% 71
Uzbekistan Uzbekistan 95.6 -1.55% 17
St. Vincent & Grenadines St. Vincent & Grenadines 106 -2.58% 5
Vietnam Vietnam 101 +0.265% 9
Vanuatu Vanuatu 58.3 +0.0296% 62
Samoa Samoa 94.1 -4.5% 25

                    
# 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.CMPT.LO.ZS'

# 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.CMPT.LO.ZS'

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