Present value of external debt (current US$)

Source: worldbank.org, 03.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Afghanistan Afghanistan 2,717,456,906 86
Angola Angola 45,299,080,954 15
Albania Albania 5,362,844,332 69
Argentina Argentina 74,362,126,635 12
Armenia Armenia 6,002,119,812 65
Azerbaijan Azerbaijan 12,378,043,481 43
Burundi Burundi 805,174,024 107
Benin Benin 6,308,525,869 64
Burkina Faso Burkina Faso 3,564,628,102 80
Bangladesh Bangladesh 58,019,912,234 14
Bosnia & Herzegovina Bosnia & Herzegovina 5,358,602,836 70
Belarus Belarus 18,010,423,590 35
Belize Belize 1,234,635,750 101
Bolivia Bolivia 11,174,222,638 45
Brazil Brazil 198,581,760,408 5
Bhutan Bhutan 2,827,240,826 85
Botswana Botswana 1,761,068,907 96
Central African Republic Central African Republic 724,178,719 109
China China 488,114,430,989 1
Côte d’Ivoire Côte d’Ivoire 26,576,227,605 27
Cameroon Cameroon 11,111,521,906 46
Congo - Kinshasa Congo - Kinshasa 7,925,744,452 55
Congo - Brazzaville Congo - Brazzaville 6,359,540,094 63
Colombia Colombia 108,026,994,407 8
Comoros Comoros 267,652,062 117
Cape Verde Cape Verde 1,385,484,601 99
Costa Rica Costa Rica 15,574,466,789 39
Djibouti Djibouti 2,530,962,403 90
Dominica Dominica 301,190,977 114
Dominican Republic Dominican Republic 35,044,188,540 23
Algeria Algeria 4,763,524,406 71
Ecuador Ecuador 39,658,272,057 20
Egypt Egypt 117,272,019,091 7
Eritrea Eritrea 461,375,610 111
Ethiopia Ethiopia 25,425,886,135 30
Fiji Fiji 1,396,955,720 98
Gabon Gabon 6,442,260,722 62
Georgia Georgia 9,084,713,527 50
Ghana Ghana 29,240,959,315 26
Guinea Guinea 3,763,776,959 75
Gambia Gambia 902,420,744 104
Guinea-Bissau Guinea-Bissau 896,812,461 106
Grenada Grenada 501,370,822 110
Guatemala Guatemala 11,861,889,799 44
Guyana Guyana 1,805,467,108 95
Honduras Honduras 7,785,193,767 56
Haiti Haiti 1,864,980,665 94
Indonesia Indonesia 225,272,618,383 3
India India 212,727,581,325 4
Iran Iran 6,758,872,221 58
Iraq Iraq 15,579,559,160 38
Jamaica Jamaica 9,636,387,272 48
Jordan Jordan 21,057,534,515 34
Kazakhstan Kazakhstan 25,765,121,490 28
Kenya Kenya 31,450,955,158 25
Kyrgyzstan Kyrgyzstan 3,617,000,759 79
Cambodia Cambodia 8,019,432,736 54
Laos Laos 9,619,160,982 49
Lebanon Lebanon 41,936,178,302 19
Liberia Liberia 1,335,258,352 100
St. Lucia St. Lucia 901,316,744 105
Sri Lanka Sri Lanka 42,198,486,929 18
Lesotho Lesotho 928,019,428 102
Morocco Morocco 42,261,909,461 17
Moldova Moldova 2,637,352,676 88
Madagascar Madagascar 3,548,448,009 81
Maldives Maldives 3,112,680,608 82
Mexico Mexico 306,307,546,450 2
North Macedonia North Macedonia 5,636,939,246 67
Mali Mali 4,084,725,522 73
Myanmar (Burma) Myanmar (Burma) 8,747,522,563 51
Montenegro Montenegro 3,642,880,942 77
Mongolia Mongolia 8,379,162,780 52
Mozambique Mozambique 8,273,627,343 53
Mauritania Mauritania 3,072,186,082 83
Mauritius Mauritius 3,632,054,534 78
Malawi Malawi 2,269,371,135 92
Niger Niger 3,793,079,744 74
Nigeria Nigeria 45,008,756,409 16
Nicaragua Nicaragua 6,753,035,610 59
Nepal Nepal 5,719,004,452 66
Pakistan Pakistan 89,147,983,857 11
Peru Peru 38,102,037,997 21
Philippines Philippines 63,241,457,455 13
Papua New Guinea Papua New Guinea 7,011,135,646 57
Paraguay Paraguay 13,782,721,185 41
Rwanda Rwanda 5,531,140,261 68
Sudan Sudan 21,650,006,462 32
Senegal Senegal 14,985,103,560 40
Solomon Islands Solomon Islands 184,191,155 119
Sierra Leone Sierra Leone 1,451,469,588 97
El Salvador El Salvador 12,667,873,106 42
Somalia Somalia 2,562,539,725 89
Serbia Serbia 21,725,736,069 31
São Tomé & Príncipe São Tomé & Príncipe 327,247,986 113
Suriname Suriname 2,644,809,681 87
Eswatini Eswatini 923,265,790 103
Syria Syria 4,572,551,074 72
Chad Chad 2,285,944,346 91
Togo Togo 1,923,381,711 93
Thailand Thailand 37,064,630,306 22
Tajikistan Tajikistan 3,023,691,992 84
Turkmenistan Turkmenistan 3,696,341,106 76
Timor-Leste Timor-Leste 238,042,047 118
Tonga Tonga 159,275,824 120
Tunisia Tunisia 21,211,882,696 33
Turkey Turkey 149,654,359,761 6
Tanzania Tanzania 17,512,795,067 36
Uganda Uganda 10,469,028,424 47
Ukraine Ukraine 90,003,458,680 10
Uzbekistan Uzbekistan 25,713,533,796 29
St. Vincent & Grenadines St. Vincent & Grenadines 456,970,636 112
Vietnam Vietnam 34,425,830,777 24
Vanuatu Vanuatu 299,745,789 115
Samoa Samoa 269,974,494 116
Kosovo Kosovo 785,738,778 108
Yemen Yemen 6,492,149,296 61
South Africa South Africa 93,879,471,101 9
Zambia Zambia 16,596,564,417 37
Zimbabwe Zimbabwe 6,671,220,476 60

                    
# 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.DOD.PVLX.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.DOD.PVLX.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))