Persistence to last grade of primary, female (% of cohort)

Source: worldbank.org, 01.09.2025

Year: 2009

Flag Country Value Value change, % Rank
Angola Angola 26.9 +4.4% 97
Albania Albania 95.4 +1.12% 39
Argentina Argentina 93.8 +0.96% 46
Armenia Armenia 97.8 +0.417% 24
Azerbaijan Azerbaijan 97.5 +0.871% 26
Burundi Burundi 61.1 -4.41% 83
Benin Benin 51.4 -18.9% 89
Burkina Faso Burkina Faso 66.6 -6.9% 79
Bangladesh Bangladesh 70.6 +6.91% 73
Bulgaria Bulgaria 97.1 +3.8% 29
Bahamas Bahamas 87.7 +0.34% 57
Bosnia & Herzegovina Bosnia & Herzegovina 98.4 19
Belize Belize 91.4 -4.95% 50
Bolivia Bolivia 84.6 63
Brunei Brunei 96.3 +0.151% 35
Bhutan Bhutan 91.7 -3.34% 49
Central African Republic Central African Republic 38.9 -4.5% 92
Cameroon Cameroon 65.4 -5.25% 81
Congo - Kinshasa Congo - Kinshasa 51.1 -30.2% 90
Colombia Colombia 85.1 -4.62% 62
Costa Rica Costa Rica 90 -5.83% 56
Cuba Cuba 96.1 +0.682% 36
Czechia Czechia 99.1 -0.73% 13
Germany Germany 96.8 +0.725% 33
Dominica Dominica 90.4 +2.02% 55
Denmark Denmark 99.2 -0.345% 11
Algeria Algeria 97.1 +2.55% 28
Ecuador Ecuador 91.3 -0.481% 51
Egypt Egypt 96.6 +2.53% 34
Eritrea Eritrea 66.9 -7.06% 78
Estonia Estonia 97.6 -0.983% 25
Ethiopia Ethiopia 37.5 -9.28% 93
Finland Finland 99.9 +0.638% 2
Georgia Georgia 98.6 +4.46% 18
Guinea Guinea 56.2 -0.672% 87
Equatorial Guinea Equatorial Guinea 64.3 +14.4% 82
Guatemala Guatemala 67.9 -13.9% 76
Hong Kong SAR China Hong Kong SAR China 99.2 -0.286% 9
Honduras Honduras 83.8 +12% 65
Croatia Croatia 99.6 +0.35% 5
Hungary Hungary 98 +0.147% 23
Iran Iran 93.5 -2.61% 47
Iceland Iceland 98.7 +0.279% 17
Italy Italy 99.8 -0.169% 3
Kazakhstan Kazakhstan 99.1 -0.095% 12
Kyrgyzstan Kyrgyzstan 97.3 +0.609% 27
St. Kitts & Nevis St. Kitts & Nevis 69.6 +2.32% 75
South Korea South Korea 99.3 +0.605% 8
Kuwait Kuwait 96 -3.02% 38
Laos Laos 71.5 +3.14% 72
St. Lucia St. Lucia 90.6 -4.68% 53
Liechtenstein Liechtenstein 78.1 -6.85% 67
Lesotho Lesotho 76.8 +5.68% 69
Lithuania Lithuania 98.4 -0.238% 20
Latvia Latvia 94.5 -1.18% 43
Morocco Morocco 90.4 +15.4% 54
Moldova Moldova 97 +1.48% 32
Madagascar Madagascar 35.4 -29.8% 94
Mexico Mexico 95.2 +0.0612% 40
Mali Mali 75.7 -1.38% 70
Myanmar (Burma) Myanmar (Burma) 77.5 +11.9% 68
Mozambique Mozambique 33.7 -4.64% 95
Mauritius Mauritius 97 -1.18% 31
Malawi Malawi 53.6 +28.4% 88
Namibia Namibia 87 +2.08% 58
Niger Niger 60.4 -4.95% 85
Nigeria Nigeria 66.6 -16.2% 80
Norway Norway 98.9 -0.179% 15
Pakistan Pakistan 58.9 -1.6% 86
Panama Panama 93.8 +6.68% 45
Peru Peru 91 +3.91% 52
Poland Poland 99.5 +1.8% 7
Paraguay Paraguay 83.9 +4.52% 64
Romania Romania 97.1 +2.82% 30
Rwanda Rwanda 39 -2.88% 91
Sudan Sudan 72.4 71
Senegal Senegal 61.1 +3.85% 84
El Salvador El Salvador 87 +11.4% 59
Serbia Serbia 98.7 +1.51% 16
Suriname Suriname 78.7 -21% 66
Slovakia Slovakia 98.4 +0.508% 21
Slovenia Slovenia 98.9 -0.45% 14
Sweden Sweden 99.6 +0.287% 6
Eswatini Eswatini 86.7 +17.9% 60
Syria Syria 94.9 +0.702% 42
Chad Chad 27 +8.03% 96
Togo Togo 67.2 +8.34% 77
Tajikistan Tajikistan 99.2 -0.0119% 10
Timor-Leste Timor-Leste 70.3 -9.76% 74
Trinidad & Tobago Trinidad & Tobago 92.1 -0.726% 48
Tunisia Tunisia 95.1 -0.356% 41
Turkey Turkey 100 +7.5% 1
Tanzania Tanzania 86.7 +12.8% 61
Ukraine Ukraine 98.1 +0.204% 22
Uruguay Uruguay 96 -0.954% 37
Uzbekistan Uzbekistan 99.8 +0.86% 4
Venezuela Venezuela 94.2 -0.551% 44

                    
# 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.PRSL.FE.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.PRSL.FE.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))