School enrollment, primary, private (% of total primary)

Source: worldbank.org, 03.09.2025

Year: 2022

Flag Country Value Value change, % Rank
Albania Albania 10.5 +13.2% 58
Andorra Andorra 4.68 +28.3% 84
Argentina Argentina 25.3 +0.845% 25
Armenia Armenia 2.89 +11.8% 92
Australia Australia 30.9 +2.34% 17
Austria Austria 6.3 -0.534% 75
Azerbaijan Azerbaijan 1.06 +7.67% 105
Belgium Belgium 54.1 -0.105% 6
Benin Benin 25.8 +3.06% 23
Burkina Faso Burkina Faso 26.3 +7.91% 21
Bulgaria Bulgaria 2.09 +1.86% 95
Bahrain Bahrain 38 +2.26% 12
Bosnia & Herzegovina Bosnia & Herzegovina 2.01 +5.61% 96
Belarus Belarus 0.269 +18.6% 112
Belize Belize 81 -0.395% 2
Bolivia Bolivia 9.33 +2.38% 61
Brazil Brazil 18.3 +4.64% 36
Barbados Barbados 13.3 -0.0347% 47
Canada Canada 6.58 +2.85% 73
Switzerland Switzerland 5.53 +0.916% 81
Chile Chile 62.9 -0.162% 5
China China 8.82 -1.63% 66
Côte d’Ivoire Côte d’Ivoire 18.1 +1.53% 37
Cameroon Cameroon 25.8 +4.15% 22
Colombia Colombia 19.3 +5.17% 33
Costa Rica Costa Rica 9.26 +8.51% 62
Cayman Islands Cayman Islands 48.8 +6.72% 7
Cyprus Cyprus 11.9 +6.56% 54
Czechia Czechia 3.82 +9.92% 88
Germany Germany 5.29 +0.39% 82
Djibouti Djibouti 17.9 +0.339% 38
Dominica Dominica 40.9 -0.751% 11
Denmark Denmark 18.3 +1.68% 35
Dominican Republic Dominican Republic 19.4 +17.3% 32
Algeria Algeria 1.48 +14.6% 101
Ecuador Ecuador 23.7 +6.93% 27
Egypt Egypt 8.69 -2.29% 68
Spain Spain 31.9 +0.539% 16
Estonia Estonia 7.37 +4.2% 71
Finland Finland 1.75 +2.04% 99
France France 15.2 +0.735% 45
United Kingdom United Kingdom 36.8 +3.91% 13
Georgia Georgia 9.97 -4.75% 59
Ghana Ghana 28.4 -8% 19
Gibraltar Gibraltar 9.46 +3.99% 60
Greece Greece 6.91 +1.47% 72
Guatemala Guatemala 11.2 -3.51% 55
Hong Kong SAR China Hong Kong SAR China 19.7 +1.99% 31
Honduras Honduras 11.1 +4.04% 56
Croatia Croatia 1.18 +10.6% 103
Hungary Hungary 20.5 +7.17% 29
Ireland Ireland 0.998 -5.56% 107
Iceland Iceland 3.38 +9.08% 91
Israel Israel 24 +0.48% 26
Italy Italy 6.15 +0.489% 77
Jamaica Jamaica 12.2 +22.6% 52
Jordan Jordan 29.1 -1.14% 18
Japan Japan 1.26 +2.06% 102
South Korea South Korea 1.63 +2.84% 100
Lebanon Lebanon 71.4 +4.81% 3
St. Lucia St. Lucia 6.51 +8.85% 74
Lesotho Lesotho 3.75 -56.7% 89
Lithuania Lithuania 5.74 +9.87% 79
Luxembourg Luxembourg 11.1 -2.25% 57
Latvia Latvia 3.75 +24.9% 90
Macao SAR China Macao SAR China 96.8 -0.287% 1
Morocco Morocco 17.1 +5.63% 40
Monaco Monaco 32.5 +3.15% 15
Moldova Moldova 2.51 +12.9% 93
Mexico Mexico 9.09 +1.86% 63
Marshall Islands Marshall Islands 20 +3.32% 30
North Macedonia North Macedonia 0.734 +0.323% 108
Malta Malta 41.9 -0.186% 10
Montenegro Montenegro 0.516 +11.8% 110
Mozambique Mozambique 1.97 +0.0609% 98
Niger Niger 4.03 +5.68% 86
Nicaragua Nicaragua 15.6 +0.15% 43
Netherlands Netherlands 0.318 -10.3% 111
Norway Norway 3.92 +2.52% 87
New Zealand New Zealand 2.16 +8.48% 94
Oman Oman 15.2 +0.856% 44
Panama Panama 13.1 -3.68% 48
Peru Peru 25.6 +15.2% 24
Poland Poland 7.5 +6.08% 70
Portugal Portugal 13 +0.871% 49
Paraguay Paraguay 20.5 +1.41% 28
Palestinian Territories Palestinian Territories 43.6 -0.406% 8
Qatar Qatar 63.6 +0.228% 4
Romania Romania 1.98 +14.1% 97
Russia Russia 1.1 +12% 104
Rwanda Rwanda 5.01 +2.73% 83
Saudi Arabia Saudi Arabia 12.7 -9.69% 50
Senegal Senegal 17.8 -0.6% 39
Singapore Singapore 4.51 +2.41% 85
El Salvador El Salvador 12.3 -0.166% 51
Serbia Serbia 0.245 +14.6% 113
Slovakia Slovakia 8.94 +10.5% 65
Slovenia Slovenia 1.04 +2.11% 106
Sweden Sweden 12.1 +3.51% 53
Seychelles Seychelles 14.9 +1.85% 46
Syria Syria 6.21 +2.1% 76
Turks & Caicos Islands Turks & Caicos Islands 43.2 +5.14% 9
Chad Chad 18.6 +7.55% 34
Togo Togo 33.1 +0.403% 14
Trinidad & Tobago Trinidad & Tobago 8.75 +21.2% 67
Tunisia Tunisia 8.46 +9.05% 69
Turkey Turkey 5.74 +13.6% 80
Tuvalu Tuvalu 16.6 +0.042% 42
Uruguay Uruguay 16.6 +0.734% 41
United States United States 9.07 -3.46% 64
Uzbekistan Uzbekistan 0.726 +18.4% 109
British Virgin Islands British Virgin Islands 27.3 -7.93% 20
South Africa South Africa 5.79 +5.14% 78

                    
# 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.PRIV.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.PRM.PRIV.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))