Public and publicly guaranteed debt service (% of GNI)

Source: worldbank.org, 03.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Afghanistan Afghanistan 0.0767 -7.19% 114
Angola Angola 13.8 +54.2% 1
Albania Albania 1.97 -4.09% 56
Argentina Argentina 1.59 +2.92% 70
Armenia Armenia 3.04 +37.9% 36
Azerbaijan Azerbaijan 2.18 +13.4% 53
Burundi Burundi 1.02 +34.3% 88
Benin Benin 4.07 +54.6% 20
Burkina Faso Burkina Faso 1.18 +15.8% 81
Bangladesh Bangladesh 0.973 +36.8% 93
Bosnia & Herzegovina Bosnia & Herzegovina 3.1 +58.6% 35
Belarus Belarus 6.32 +25.4% 6
Belize Belize 3.6 +36.3% 27
Bolivia Bolivia 3.4 -19.6% 31
Brazil Brazil 1.49 -8.9% 73
Bhutan Bhutan 4.74 +0.769% 15
Botswana Botswana 1.1 +41.3% 86
Central African Republic Central African Republic 0.242 -15.3% 111
China China 0.299 -25.5% 110
Côte d’Ivoire Côte d’Ivoire 3.62 +50.5% 26
Cameroon Cameroon 2.86 -24.5% 41
Congo - Kinshasa Congo - Kinshasa 0.615 +10.3% 104
Congo - Brazzaville Congo - Brazzaville 5.18 -15.8% 12
Colombia Colombia 3.81 +44.2% 23
Comoros Comoros 0.727 +462% 101
Cape Verde Cape Verde 5.38 +23% 10
Costa Rica Costa Rica 3.15 +74.8% 34
Djibouti Djibouti 1.22 -14.5% 79
Dominica Dominica 4.66 +1.45% 17
Dominican Republic Dominican Republic 3.64 +25.6% 25
Algeria Algeria 0.047 -17.3% 115
Ecuador Ecuador 2.83 +0.0613% 42
Egypt Egypt 4.01 +26.1% 21
Fiji Fiji 2.75 +24.9% 44
Gabon Gabon 5.27 +100% 11
Georgia Georgia 2.43 +13.9% 50
Ghana Ghana 0.712 -73.5% 102
Guinea Guinea 1 +19.4% 90
Gambia Gambia 1.67 +2.78% 68
Guinea-Bissau Guinea-Bissau 2.15 -27.8% 55
Grenada Grenada 4 -2.06% 22
Guatemala Guatemala 0.935 -44.1% 95
Guyana Guyana 0.73 -22.3% 100
Honduras Honduras 2.73 +12.6% 46
Haiti Haiti 0.204 +36.7% 112
Indonesia Indonesia 1.95 -36.8% 58
India India 0.614 +15% 105
Iran Iran 0.0186 +24% 116
Iraq Iraq 1.59 +7.38% 71
Jamaica Jamaica 7.32 +12.9% 4
Jordan Jordan 4.68 -37.5% 16
Kazakhstan Kazakhstan 1.37 -10.3% 75
Kenya Kenya 3.21 +22.1% 33
Kyrgyzstan Kyrgyzstan 1.84 -10.3% 64
Cambodia Cambodia 1.2 -0.526% 80
Laos Laos 4.48 +38.1% 18
Lebanon Lebanon 0.985 +38.6% 92
Liberia Liberia 0.844 +1.49% 98
St. Lucia St. Lucia 2.78 +22% 43
Sri Lanka Sri Lanka 1.9 -31.7% 62
Lesotho Lesotho 2.69 +19.8% 47
Morocco Morocco 2.49 -31.7% 49
Moldova Moldova 3.02 +225% 37
Madagascar Madagascar 1.14 +25.7% 83
Maldives Maldives 7.1 -35.8% 5
Mexico Mexico 1.55 -9.64% 72
North Macedonia North Macedonia 5.96 +131% 9
Mali Mali 1.29 -1.2% 77
Myanmar (Burma) Myanmar (Burma) 1.17 -20.6% 82
Montenegro Montenegro 4.99 -20.9% 13
Mongolia Mongolia 10.6 -23.4% 2
Mozambique Mozambique 2.92 -14.9% 40
Mauritania Mauritania 3.37 -1.75% 32
Mauritius Mauritius 8.59 +560% 3
Malawi Malawi 0.891 +5.79% 97
Niger Niger 0.896 -51.1% 96
Nigeria Nigeria 1.01 +61.5% 89
Nicaragua Nicaragua 3.44 +16% 29
Nepal Nepal 0.844 +13.2% 99
Pakistan Pakistan 3.56 -4.32% 28
Peru Peru 1.81 +83.5% 65
Philippines Philippines 1.26 -1.68% 78
Papua New Guinea Papua New Guinea 1.67 +34.4% 69
Paraguay Paraguay 3.02 +23.7% 38
Rwanda Rwanda 2.17 +69.8% 54
Sudan Sudan 0.41 +21.9% 107
Senegal Senegal 4.34 +15.3% 19
Solomon Islands Solomon Islands 0.366 -5.19% 108
Sierra Leone Sierra Leone 1.1 +16.1% 85
El Salvador El Salvador 6.01 +0.805% 8
Somalia Somalia 0.147 -3.14% 113
Serbia Serbia 2.73 +14.7% 45
São Tomé & Príncipe São Tomé & Príncipe 0.627 -50.2% 103
Suriname Suriname 4.79 +86.9% 14
Eswatini Eswatini 1.74 +42.1% 66
Syria Syria 0 117
Chad Chad 1.94 -12.9% 59
Togo Togo 1.91 -15% 61
Thailand Thailand 1 +155% 91
Tajikistan Tajikistan 1.73 -8.47% 67
Turkmenistan Turkmenistan 1.89 -0.553% 63
Timor-Leste Timor-Leste 0.942 +98.7% 94
Tonga Tonga 2.99 +51.6% 39
Tunisia Tunisia 6.12 -3.59% 7
Turkey Turkey 2.19 -8.05% 52
Tanzania Tanzania 2.41 +15.3% 51
Uganda Uganda 1.96 +29% 57
Ukraine Ukraine 1.03 -27.1% 87
Uzbekistan Uzbekistan 1.94 +40.6% 60
St. Vincent & Grenadines St. Vincent & Grenadines 3.41 -0.815% 30
Vietnam Vietnam 1.13 +1.03% 84
Vanuatu Vanuatu 1.41 -8.94% 74
Samoa Samoa 3.78 -9.74% 24
Kosovo Kosovo 0.468 -8.55% 106
South Africa South Africa 2.68 -22% 48
Zambia Zambia 1.34 -16.3% 76
Zimbabwe Zimbabwe 0.309 +178% 109

                    
# 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.TDS.DPPG.GN.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 <- 'DT.TDS.DPPG.GN.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))