Net incurrence of liabilities, total (% of GDP)

Source: worldbank.org, 01.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Albania Albania 2.95 +68.3% 44
United Arab Emirates United Arab Emirates 0.761 +2.96% 59
Argentina Argentina 4.7 -24.6% 26
Armenia Armenia 3.04 -18.9% 41
Burkina Faso Burkina Faso 5.91 -35.6% 12
Bahamas Bahamas 2.96 -52% 43
Bosnia & Herzegovina Bosnia & Herzegovina 2.33 +130% 50
Belarus Belarus -1.08 -155% 65
Brazil Brazil 6.87 +42.7% 9
Botswana Botswana 0.314 -4.76% 62
Canada Canada 2.15 -24% 52
Switzerland Switzerland 1.59 +102% 55
Chile Chile 1.72 -27.8% 54
China China 3.22 +52.7% 39
Côte d’Ivoire Côte d’Ivoire 5.02 -32.4% 23
Colombia Colombia 5.32 -3.64% 21
Costa Rica Costa Rica 3.91 +6.58% 34
Denmark Denmark -1.94 -60.1% 66
Dominican Republic Dominican Republic 3.13 -9.22% 40
Spain Spain 4.14 -38.1% 31
Ethiopia Ethiopia 3.91 -8.4% 35
Fiji Fiji 4.27 -65% 29
United Kingdom United Kingdom 7.94 +63.1% 8
Georgia Georgia 2.83 -26.3% 45
Guinea-Bissau Guinea-Bissau 8.57 +19.9% 7
Guatemala Guatemala 0.97 -19.6% 58
Iceland Iceland 2.63 -33.7% 48
Israel Israel 3.87 -364% 37
Jordan Jordan 6.53 +32.1% 10
Kazakhstan Kazakhstan 2.38 -1.46% 49
Kenya Kenya 5.85 -18.1% 13
Kyrgyzstan Kyrgyzstan 2.29 -32.7% 51
Cambodia Cambodia 2.79 +13.3% 46
Kiribati Kiribati -2.94 +482% 68
South Korea South Korea 2.79 -30.1% 47
Sri Lanka Sri Lanka 10.1 -2.15% 3
Latvia Latvia 4.1 -29.6% 32
Morocco Morocco 5.39 +23.2% 19
Moldova Moldova 4.84 +5.44% 25
Madagascar Madagascar 6.04 +46.3% 11
Mexico Mexico 4.6 +17.1% 27
North Macedonia North Macedonia 4.97 +37.7% 24
Mauritius Mauritius 5.57 +98.3% 17
Malaysia Malaysia 5.08 -8.38% 22
Namibia Namibia 3.89 -41.1% 36
Philippines Philippines 5.54 -18.3% 18
Papua New Guinea Papua New Guinea 3.85 -21.9% 38
Paraguay Paraguay 4.15 +52.2% 30
Russia Russia 0.604 -53.3% 60
Rwanda Rwanda 5.76 -40% 15
Saudi Arabia Saudi Arabia 1.27 +3.39% 57
Senegal Senegal 9.38 +8.19% 4
Singapore Singapore 12.9 +526% 2
El Salvador El Salvador 1.98 +6.47% 53
Somalia Somalia -0.000569 64
Togo Togo 5.78 -8.43% 14
Thailand Thailand 2.99 -36.3% 42
Tajikistan Tajikistan 0.597 +7.9% 61
Tonga Tonga 0.0577 -105% 63
Turkey Turkey 8.93 +26% 6
Tanzania Tanzania 4.06 +39.7% 33
Uganda Uganda 5.67 +13.7% 16
Ukraine Ukraine 18.5 +18.3% 1
Uruguay Uruguay 5.33 +106% 20
United States United States 9.06 +76.3% 5
Uzbekistan Uzbekistan 4.44 +1,130% 28
Vanuatu Vanuatu 1.36 -55.4% 56
Samoa Samoa -2.72 +24.2% 67

                    
# 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 = 'GC.LBL.TOTL.GD.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 <- 'GC.LBL.TOTL.GD.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))