Educational attainment, at least completed upper secondary, population 25+, total (%) (cumulative)

Source: worldbank.org, 03.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Australia Australia 79 -3.31% 13
Austria Austria 82.6 +0.573% 10
Azerbaijan Azerbaijan 91.8 -1.18% 5
Burkina Faso Burkina Faso 5.26 -1.22% 53
Bahrain Bahrain 66.7 -0.329% 22
Bahamas Bahamas 90.9 +5.87% 6
Bosnia & Herzegovina Bosnia & Herzegovina 72 -0.377% 17
Belarus Belarus 97.9 -0.00482% 1
Bolivia Bolivia 52.1 +2.8% 30
Brazil Brazil 60.1 +11.3% 27
Botswana Botswana 46 +2.39% 33
Canada Canada 89.6 +0.444% 7
Switzerland Switzerland 84.3 +0.43% 8
Chile Chile 68.4 +2.69% 20
Colombia Colombia 57 +1.68% 28
Costa Rica Costa Rica 39.9 -2.61% 39
Dominican Republic Dominican Republic 36 -17.7% 43
Spain Spain 55.2 -0.18% 29
France France 78 +4.88% 14
United Kingdom United Kingdom 79.4 +1.37% 12
Georgia Georgia 93.2 +0.366% 3
Gambia Gambia 29 +43.2% 47
Guatemala Guatemala 17.6 -2.84% 51
Hong Kong SAR China Hong Kong SAR China 65.8 +1.09% 23
Honduras Honduras 19.2 +21.7% 50
Indonesia Indonesia 39.1 -1.16% 41
India India 33.7 +6.61% 46
Jordan Jordan 42.6 -15.3% 36
South Korea South Korea 80.9 +1.37% 11
Latvia Latvia 69.2 -22% 19
Moldova Moldova 75.4 +0.903% 16
Mexico Mexico 40.9 +7.82% 38
North Macedonia North Macedonia 72 +2.03% 18
Mongolia Mongolia 82.9 +4.75% 9
Panama Panama 51.1 -0.304% 31
Peru Peru 64.5 +14.2% 25
Poland Poland 67 -24% 21
Portugal Portugal 47.4 -1.48% 32
Russia Russia 92.7 +0.764% 4
Rwanda Rwanda 14.6 +8.67% 52
Saudi Arabia Saudi Arabia 64.8 +0.184% 24
Singapore Singapore 63.4 -19.8% 26
El Salvador El Salvador 33.8 -5.95% 44
Serbia Serbia 76.1 +1.55% 15
Eswatini Eswatini 19.4 -45.9% 49
Thailand Thailand 39.4 +0.28% 40
Tunisia Tunisia 43.9 +126% 35
Turkey Turkey 41.1 +4.58% 37
Uruguay Uruguay 33.7 -3.08% 45
United States United States 95.3 +4.5% 2
Vietnam Vietnam 39.1 -6.74% 42
Yemen Yemen 25.6 +37.7% 48
South Africa South Africa 44.2 +3.53% 34

                    
# 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.CUAT.UP.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.CUAT.UP.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))