External debt stocks, public and publicly guaranteed (PPG) (DOD, current US$)

Source: worldbank.org, 01.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Afghanistan Afghanistan 1,856,685,293 -0.146% 93
Angola Angola 45,215,431,910 -6.11% 15
Albania Albania 5,553,453,421 +14.3% 67
Argentina Argentina 126,389,609,250 -1.21% 7
Armenia Armenia 6,241,069,251 -1.24% 63
Azerbaijan Azerbaijan 12,232,760,096 -5.25% 46
Burundi Burundi 607,085,975 +4.97% 108
Benin Benin 7,171,518,906 +19.7% 58
Burkina Faso Burkina Faso 4,900,139,223 +11.8% 71
Bangladesh Bangladesh 74,131,225,879 +9.63% 13
Bosnia & Herzegovina Bosnia & Herzegovina 5,126,462,733 +0.0177% 69
Belarus Belarus 17,500,179,876 -8.89% 35
Belize Belize 1,347,047,704 +3.44% 97
Bolivia Bolivia 13,660,338,072 +2.16% 42
Brazil Brazil 190,753,737,192 +0.103% 5
Bhutan Bhutan 3,190,019,816 +3.68% 82
Botswana Botswana 1,457,909,838 -6.45% 96
Central African Republic Central African Republic 442,796,838 +3.01% 111
China China 467,995,987,954 +0.782% 1
Côte d’Ivoire Côte d’Ivoire 29,168,830,424 +11% 27
Cameroon Cameroon 12,058,078,118 +1.73% 47
Congo - Kinshasa Congo - Kinshasa 6,467,510,547 +16.2% 62
Congo - Brazzaville Congo - Brazzaville 6,864,903,470 -3.73% 61
Colombia Colombia 103,450,019,698 +5.94% 9
Comoros Comoros 320,487,437 +5.7% 116
Cape Verde Cape Verde 1,933,793,921 +0.702% 92
Costa Rica Costa Rica 15,082,915,114 +9.89% 40
Djibouti Djibouti 2,836,358,659 +17.7% 85
Dominica Dominica 364,023,161 +7.39% 114
Dominican Republic Dominican Republic 38,277,356,606 +7.64% 22
Algeria Algeria 992,763,508 -5.96% 102
Ecuador Ecuador 39,657,985,905 +0.443% 21
Egypt Egypt 117,380,489,561 +6.52% 8
Eritrea Eritrea 641,297,476 -0.768% 107
Ethiopia Ethiopia 31,914,034,150 +9.87% 26
Fiji Fiji 1,594,834,197 -0.501% 95
Gabon Gabon 6,090,214,800 -1.66% 64
Georgia Georgia 10,263,537,679 +5.56% 50
Ghana Ghana 28,538,104,558 +3.21% 29
Guinea Guinea 3,931,210,042 +7.18% 76
Gambia Gambia 982,634,487 +10.2% 103
Guinea-Bissau Guinea-Bissau 1,018,181,455 +4.29% 100
Grenada Grenada 605,738,922 +7.06% 109
Guatemala Guatemala 12,553,659,265 +12.1% 44
Guyana Guyana 1,725,929,086 +13.6% 94
Honduras Honduras 8,816,902,402 -2.17% 54
Haiti Haiti 2,079,103,488 -1.52% 89
Indonesia Indonesia 234,906,670,197 +3.84% 3
India India 214,915,658,330 +4.73% 4
Iran Iran 388,146,480 -2.16% 112
Iraq Iraq 15,698,548,004 -12.5% 37
Jamaica Jamaica 8,357,514,391 -4.4% 56
Jordan Jordan 22,491,062,969 +17% 34
Kazakhstan Kazakhstan 25,230,928,888 -5.89% 31
Kenya Kenya 35,863,712,409 +2.36% 23
Kyrgyzstan Kyrgyzstan 4,192,256,560 +4% 74
Cambodia Cambodia 11,098,460,872 +10.2% 48
Laos Laos 11,033,817,235 -1.16% 49
Lebanon Lebanon 33,553,419,342 +0.533% 24
Liberia Liberia 1,274,045,821 +14.8% 99
St. Lucia St. Lucia 930,117,382 +26.3% 104
Sri Lanka Sri Lanka 41,382,416,242 +7.52% 19
Lesotho Lesotho 998,543,298 +3.16% 101
Morocco Morocco 45,116,709,744 +9.28% 16
Moldova Moldova 2,629,560,437 +16.3% 86
Madagascar Madagascar 4,482,340,748 +13.9% 73
Maldives Maldives 3,418,011,648 +11.4% 81
Mexico Mexico 301,047,797,836 +4.03% 2
North Macedonia North Macedonia 5,654,905,529 +11% 66
Mali Mali 5,540,991,605 +4.61% 68
Myanmar (Burma) Myanmar (Burma) 10,036,209,018 -4.03% 51
Montenegro Montenegro 3,966,321,787 +0.659% 75
Mongolia Mongolia 9,729,885,651 -0.738% 52
Mozambique Mozambique 9,523,920,083 -1.58% 53
Mauritania Mauritania 3,749,372,024 -1.93% 77
Mauritius Mauritius 3,675,389,007 +9.72% 78
Malawi Malawi 2,876,075,401 +13% 84
Niger Niger 4,833,771,078 +3.98% 72
Nigeria Nigeria 44,073,668,768 +10.1% 17
Nicaragua Nicaragua 7,081,339,764 +5.4% 60
Nepal Nepal 8,619,923,854 +8.31% 55
Pakistan Pakistan 92,990,124,743 +1.94% 10
Peru Peru 40,905,934,689 -1.3% 20
Philippines Philippines 68,742,236,441 +9.77% 14
Papua New Guinea Papua New Guinea 7,135,961,991 +5.75% 59
Paraguay Paraguay 13,882,627,577 +7.76% 41
Rwanda Rwanda 7,230,880,897 +17.7% 57
Sudan Sudan 15,364,548,060 +0.731% 39
Senegal Senegal 16,906,911,406 +16.2% 36
Solomon Islands Solomon Islands 197,630,833 +27.7% 119
Sierra Leone Sierra Leone 1,344,715,324 -0.163% 98
El Salvador El Salvador 12,509,702,261 +4.21% 45
Somalia Somalia 1,996,933,695 -13.6% 91
Serbia Serbia 25,557,855,692 +16.9% 30
São Tomé & Príncipe São Tomé & Príncipe 370,751,011 +9.32% 113
Suriname Suriname 2,402,986,027 +8.79% 87
Eswatini Eswatini 773,239,589 +2.05% 105
Syria Syria 3,501,530,081 +0.102% 80
Chad Chad 2,215,097,557 -3.27% 88
Togo Togo 2,029,689,484 +13.2% 90
Thailand Thailand 32,419,029,354 -9.13% 25
Tajikistan Tajikistan 3,090,784,260 +0.662% 83
Turkmenistan Turkmenistan 3,501,611,264 -15.1% 79
Timor-Leste Timor-Leste 254,756,411 +3.38% 118
Tonga Tonga 151,362,668 -8.38% 120
Tunisia Tunisia 22,662,510,931 +4.75% 32
Turkey Turkey 149,369,407,397 +6.54% 6
Tanzania Tanzania 22,575,278,290 +14.9% 33
Uganda Uganda 13,158,278,514 +10.1% 43
Ukraine Ukraine 87,664,445,499 +42.3% 12
Uzbekistan Uzbekistan 28,886,615,160 +17.1% 28
St. Vincent & Grenadines St. Vincent & Grenadines 575,628,523 +15% 110
Vietnam Vietnam 43,894,174,346 -5.53% 18
Vanuatu Vanuatu 362,290,706 -3.13% 115
Samoa Samoa 296,210,273 -9.92% 117
Kosovo Kosovo 694,331,737 +8.1% 106
Yemen Yemen 5,814,628,864 -1.38% 65
South Africa South Africa 89,472,937,732 -1.93% 11
Zambia Zambia 15,378,310,192 -2.1% 38
Zimbabwe Zimbabwe 5,108,699,306 +9.38% 70

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