PPG, private creditors (NFL, US$)

Source: worldbank.org, 03.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Angola Angola -2,706,320,000 -255% 94
Albania Albania 550,420,000 -1,772% 20
Argentina Argentina -1,346,250,000 -11% 87
Armenia Armenia -174,019,000 +4,615% 70
Azerbaijan Azerbaijan -321,108,000 -3,432% 79
Benin Benin 594,478,000 +746% 19
Burkina Faso Burkina Faso 30,023,000 -1,832% 33
Bangladesh Bangladesh -339,670,000 -7.61% 80
Bosnia & Herzegovina Bosnia & Herzegovina -188,462,000 +2,456% 73
Belarus Belarus -690,220,000 +338% 82
Belize Belize -5,767,000 57
Bolivia Bolivia -192,935,000 -901% 75
Brazil Brazil -2,702,726,000 -332% 93
Bhutan Bhutan -4,246,000 +2.63% 56
Central African Republic Central African Republic -479,000 -66.4% 46
China China 5,548,285,000 -306% 4
Côte d’Ivoire Côte d’Ivoire 367,606,000 -83.4% 23
Cameroon Cameroon -68,338,000 -88.4% 67
Congo - Kinshasa Congo - Kinshasa 3,472,000 -115% 37
Congo - Brazzaville Congo - Brazzaville -235,906,000 -32.4% 77
Colombia Colombia 4,170,203,000 +109% 6
Cape Verde Cape Verde -27,701,000 +170% 63
Costa Rica Costa Rica 1,773,922,000 -1,060% 12
Dominica Dominica -3,397,000 -15% 54
Dominican Republic Dominican Republic 1,567,983,000 -41.3% 13
Algeria Algeria -58,000 -92.4% 41
Ecuador Ecuador 534,097,000 -468% 21
Egypt Egypt 3,971,257,000 +256% 7
Ethiopia Ethiopia 105,841,000 -117% 29
Gabon Gabon 448,954,000 -621% 22
Georgia Georgia -25,594,000 -14.1% 62
Ghana Ghana 142,152,000 -57% 27
Guinea Guinea 178,184,000 +39.4% 26
Gambia Gambia -3,358,000 -18% 53
Grenada Grenada -10,561,000 0% 59
Guatemala Guatemala 1,563,320,000 -884% 14
Guyana Guyana -984,000 +6.38% 47
Honduras Honduras -216,250,000 +16.2% 76
Haiti Haiti -2,326,000 -33.3% 50
Indonesia Indonesia 6,129,738,000 -142% 3
India India 4,626,385,000 -371% 5
Iran Iran 544,000 -98.8% 39
Iraq Iraq -1,497,027,000 +9.17% 88
Jamaica Jamaica -188,199,000 -14.5% 72
Jordan Jordan 1,908,444,000 -340% 11
Kazakhstan Kazakhstan -1,194,419,000 -16.2% 86
Kenya Kenya 187,412,000 -352% 25
Laos Laos -179,721,000 +3,175% 71
Lebanon Lebanon 744,000 +76.3% 38
Liberia Liberia 0 40
St. Lucia St. Lucia -200,000 0% 42
Sri Lanka Sri Lanka 48,289,000 -111% 32
Lesotho Lesotho -369,000 +73.2% 44
Morocco Morocco 2,339,158,000 -251% 10
Moldova Moldova -2,114,000 -20.7% 49
Madagascar Madagascar 16,782,000 -201% 36
Maldives Maldives -16,184,000 -89.2% 61
Mexico Mexico 14,872,207,000 +35.9% 1
North Macedonia North Macedonia 49,665,000 -79.3% 31
Myanmar (Burma) Myanmar (Burma) -191,862,000 -19.4% 74
Montenegro Montenegro 18,975,000 -114% 35
Mongolia Mongolia -68,216,000 -95.7% 66
Mozambique Mozambique -113,505,000 +9.89% 68
Mauritius Mauritius 53,863,000 -90.8% 30
Niger Niger -7,728,000 +2.64% 58
Nigeria Nigeria -980,729,000 -167% 85
Nicaragua Nicaragua -2,723,000 +38.4% 51
Nepal Nepal -262,000 +394% 43
Pakistan Pakistan -1,655,714,000 -50.3% 89
Peru Peru -1,778,341,000 -396% 90
Philippines Philippines 2,900,995,000 +0.0454% 8
Papua New Guinea Papua New Guinea -11,062,000 +39.6% 60
Paraguay Paraguay 192,146,000 -10.6% 24
Rwanda Rwanda 133,713,000 +11.9% 28
Sudan Sudan 0 40
Senegal Senegal 1,149,149,000 +961% 16
El Salvador El Salvador -594,223,000 -3.32% 81
Serbia Serbia 2,666,101,000 +278% 9
Suriname Suriname -4,147,000 +16.1% 55
Eswatini Eswatini 0 40
Syria Syria 0 40
Chad Chad -261,500,000 -13% 78
Togo Togo 23,952,000 -617% 34
Thailand Thailand -2,454,871,000 +197% 92
Tajikistan Tajikistan 0 40
Turkmenistan Turkmenistan -55,807,000 -357% 64
Tunisia Tunisia -699,206,000 +39.8% 83
Turkey Turkey 8,250,979,000 +149% 2
Tanzania Tanzania 790,699,000 -577% 17
Uganda Uganda 613,323,000 -1,256% 18
Ukraine Ukraine -139,447,000 -130% 69
Uzbekistan Uzbekistan 1,560,154,000 +248% 15
St. Vincent & Grenadines St. Vincent & Grenadines -1,695,000 -42% 48
Vietnam Vietnam -738,513,000 +11.6% 84
Kosovo Kosovo -421,000 -186% 45
South Africa South Africa -2,239,622,000 -54.7% 91
Zambia Zambia -64,217,000 -71.2% 65
Zimbabwe Zimbabwe -2,790,000 -33.7% 52

                    
# 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 = 'DT.NFL.PRVT.CD'

# 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 <- 'DT.NFL.PRVT.CD'

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