External debt stocks, short-term (DOD, current US$)

Source: worldbank.org, 01.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Afghanistan Afghanistan 426,670,507 +8.3% 73
Angola Angola 4,930,802,505 +17.6% 29
Albania Albania 1,253,577,000 -2.29% 55
Argentina Argentina 54,949,726,426 +10.7% 7
Armenia Armenia 3,106,873,000 -4.17% 40
Azerbaijan Azerbaijan 612,292,000 +20.9% 67
Burundi Burundi 294,000 +10.9% 114
Benin Benin 1,882,307,000 +24.2% 51
Burkina Faso Burkina Faso 0 118
Bangladesh Bangladesh 14,231,110,000 -23.2% 19
Bosnia & Herzegovina Bosnia & Herzegovina 2,890,855,000 +9.82% 43
Belarus Belarus 10,381,047,000 +2.34% 22
Belize Belize 11,554,000 +17.5% 108
Bolivia Bolivia 793,075,000 +25.7% 63
Brazil Brazil 80,491,601,000 +18.8% 4
Bhutan Bhutan 924,000 -83.2% 112
Botswana Botswana 290,266,000 +159% 77
Central African Republic Central African Republic 73,940,191 -27.8% 93
China China 1,287,403,080,192 +1.76% 1
Côte d’Ivoire Côte d’Ivoire 2,983,634,000 +77% 41
Cameroon Cameroon 857,975,367 -2.35% 61
Congo - Kinshasa Congo - Kinshasa 602,051,015 +2.39% 68
Congo - Brazzaville Congo - Brazzaville 197,221,814 +2.36% 81
Colombia Colombia 19,920,842,000 +2.88% 13
Comoros Comoros 454,417 -71% 113
Cape Verde Cape Verde 406,825,000 +1.4% 75
Costa Rica Costa Rica 5,421,533,000 -20.5% 28
Djibouti Djibouti 478,409,185 -23.8% 71
Dominica Dominica 177,120,000 -10.7% 82
Dominican Republic Dominican Republic 3,964,869,000 +25.2% 35
Algeria Algeria 1,912,840,000 +9.67% 50
Ecuador Ecuador 1,739,695,000 -9.55% 52
Egypt Egypt 29,483,018,550 -2.52% 11
Eritrea Eritrea 43,859,591 +8.59% 101
Ethiopia Ethiopia 215,005,565 -36.4% 79
Fiji Fiji 793,532,000 +56% 62
Gabon Gabon 123,983,148 -61.8% 87
Georgia Georgia 4,166,661,000 +9.4% 34
Ghana Ghana 3,758,421,325 -19.2% 37
Guinea Guinea 297,589,705 +20.6% 76
Gambia Gambia 91,326,024 +126% 90
Guinea-Bissau Guinea-Bissau 1,473,958 +10.8% 111
Grenada Grenada 55,269,420 -14.5% 98
Guatemala Guatemala 82,400,000 -72.7% 91
Guyana Guyana 60,278,439 +11% 96
Honduras Honduras 1,372,570,000 +38.7% 54
Haiti Haiti 88,000 0% 115
Indonesia Indonesia 54,604,607,000 +13.7% 8
India India 126,320,147,000 -1.21% 3
Iran Iran 2,285,025,929 +21% 48
Iraq Iraq 971,196,000 -15.9% 58
Jamaica Jamaica 2,617,710,000 +18.3% 47
Jordan Jordan 15,979,358,001 +1.25% 18
Kazakhstan Kazakhstan 19,257,644,000 +17.5% 14
Kenya Kenya 2,815,399,175 +9.93% 45
Kyrgyzstan Kyrgyzstan 1,124,923,000 +15.7% 56
Cambodia Cambodia 4,372,389,000 -5.15% 33
Laos Laos 140,163,210 -81.3% 85
Lebanon Lebanon 17,137,807,160 +10.5% 16
Liberia Liberia 79,159 116
St. Lucia St. Lucia 80,372,000 -17.6% 92
Sri Lanka Sri Lanka 7,249,294,945 -15.6% 26
Lesotho Lesotho 3,364,904 -76.7% 110
Morocco Morocco 10,021,134,983 +0.708% 23
Moldova Moldova 2,822,940,000 +15.3% 44
Madagascar Madagascar 128,456,615 -28.5% 86
Maldives Maldives 98,477,000 -78.2% 89
Mexico Mexico 60,138,950,000 +9.81% 6
North Macedonia North Macedonia 3,157,579,000 +1.43% 39
Mali Mali 65,385,991 +24.4% 95
Myanmar (Burma) Myanmar (Burma) 44,465,928 +40% 100
Montenegro Montenegro 173,707,000 -18.2% 83
Mongolia Mongolia 1,913,156,000 -0.212% 49
Mozambique Mozambique 933,670,715 +18.9% 60
Mauritania Mauritania 258,234,000 +25.1% 78
Mauritius Mauritius 9,443,558,000 +13.3% 24
Malawi Malawi 13,763,000 -84.8% 107
Niger Niger 43,441,378 +2.18% 102
Nigeria Nigeria 18,940,345,661 -11.8% 15
Nicaragua Nicaragua 1,029,849,000 -9.93% 57
Nepal Nepal 417,537,000 +29.7% 74
Pakistan Pakistan 8,878,336,000 +1.25% 25
Peru Peru 12,759,217,000 +21.2% 21
Philippines Philippines 17,095,780,000 +2.87% 17
Papua New Guinea Papua New Guinea 18,667,138 -99.4% 106
Paraguay Paraguay 2,763,250,477 +19.3% 46
Rwanda Rwanda 443,181,070 +17.7% 72
Sudan Sudan 4,814,828,235 +0.191% 31
Senegal Senegal 4,858,200,000 +34.4% 30
Solomon Islands Solomon Islands 40,819,000 -31.2% 103
Sierra Leone Sierra Leone 156,987,365 -2.87% 84
El Salvador El Salvador 2,911,988,000 +22.9% 42
Somalia Somalia 651,264,295 -42.5% 65
Serbia Serbia 969,657,000 -62.1% 59
São Tomé & Príncipe São Tomé & Príncipe 22,061,497 +7.71% 105
Suriname Suriname 205,701,910 -50.1% 80
Eswatini Eswatini 56,734,367 +375% 97
Syria Syria 621,892,802 +0.63% 66
Chad Chad 34,619,134 +0.927% 104
Togo Togo 100,382,000 -40.9% 88
Thailand Thailand 67,774,579,000 -0.787% 5
Tajikistan Tajikistan 677,844,000 +8.38% 64
Turkmenistan Turkmenistan 0 -100% 118
Timor-Leste Timor-Leste 9,340,000 +2,663% 109
Tonga Tonga 0 118
Tunisia Tunisia 13,771,602,000 +0.645% 20
Turkey Turkey 174,023,785,000 +17.1% 2
Tanzania Tanzania 4,377,142,199 +1.58% 32
Uganda Uganda 485,431,302 -71.8% 70
Ukraine Ukraine 21,037,112,740 +29.9% 12
Uzbekistan Uzbekistan 6,818,924,480 +8.62% 27
St. Vincent & Grenadines St. Vincent & Grenadines 905 +3.61% 117
Vietnam Vietnam 35,109,187,964 -7.98% 10
Vanuatu Vanuatu 52,522,000 +65.3% 99
Samoa Samoa 66,420,000 -6.84% 94
Kosovo Kosovo 1,453,418,685 +16.2% 53
Yemen Yemen 517,459,583 +3.67% 69
South Africa South Africa 42,218,911,000 -1.7% 9
Zambia Zambia 3,368,344,293 +28.1% 38
Zimbabwe Zimbabwe 3,939,211,893 -1.07% 36

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