Bank nonperforming loans to total gross loans (%)

Source: worldbank.org, 01.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Albania Albania 4.56 -4.86% 38
United Arab Emirates United Arab Emirates 5.31 -19% 33
Argentina Argentina 3.55 +14.7% 48
Antigua & Barbuda Antigua & Barbuda 6.05 -12.4% 26
Austria Austria 2.48 +24.4% 63
Azerbaijan Azerbaijan 1.93 -24.8% 73
Belgium Belgium 1.82 -0.974% 75
Bangladesh Bangladesh 9.57 +9.68% 14
Bulgaria Bulgaria 3.62 -20.1% 46
Bosnia & Herzegovina Bosnia & Herzegovina 3.82 -15.9% 43
Belarus Belarus 5.05 +2.83% 37
Brazil Brazil 2.84 +7.63% 58
Botswana Botswana 3.67 -2.23% 45
Central African Republic Central African Republic 16.2 +11.8% 7
Canada Canada 0.456 +33.2% 101
Switzerland Switzerland 0.827 +20.7% 100
Chile Chile 2.1 +26.4% 66
Cameroon Cameroon 12.9 -1.13% 11
Congo - Kinshasa Congo - Kinshasa 6.56 -11.7% 24
Congo - Brazzaville Congo - Brazzaville 15.2 -9.54% 8
Colombia Colombia 3.47 +40.7% 49
Costa Rica Costa Rica 1.96 -6.87% 70
Cyprus Cyprus 6.11 -20.2% 25
Czechia Czechia 1.21 -17.2% 92
Germany Germany 1.54 +24.3% 83
Denmark Denmark 0.941 -11.8% 97
Dominican Republic Dominican Republic 0.93 +12.6% 98
Ecuador Ecuador 4.24 +13.8% 41
Spain Spain 3.06 +0.0163% 55
Estonia Estonia 1.08 +35.2% 94
Finland Finland 1.29 -4.69% 90
France France 2.06 -0.812% 68
Gabon Gabon 7.58 -0.805% 20
United Kingdom United Kingdom 0.976 +3.04% 95
Georgia Georgia 1.48 -2.1% 87
Ghana Ghana 20.6 +39.1% 5
Equatorial Guinea Equatorial Guinea 31.1 -43.8% 3
Greece Greece 5.96 -27.1% 27
Guatemala Guatemala 1.75 +39.6% 77
Hong Kong SAR China Hong Kong SAR China 1.2 +18.2% 93
Croatia Croatia 3.6 -16.9% 47
Hungary Hungary 3.27 -13.8% 52
Indonesia Indonesia 1.96 -8.86% 71
India India 1.72 -64.2% 78
Ireland Ireland 1.27 -20.9% 91
Iraq Iraq 14.7 -22.2% 9
Iceland Iceland 1.58 +12.8% 81
Israel Israel 0.972 +36.6% 96
Jordan Jordan 6.8 +8.73% 22
Kazakhstan Kazakhstan 2.89 -13.9% 57
Kenya Kenya 12.3 +14.7% 12
Kyrgyzstan Kyrgyzstan 8.92 -28.4% 16
Cambodia Cambodia 5.13 +89.2% 35
St. Kitts & Nevis St. Kitts & Nevis 19.4 -11.1% 6
Kuwait Kuwait 1.42 +0.893% 89
St. Lucia St. Lucia 14.5 +13.4% 10
Lesotho Lesotho 3.84 -11% 42
Luxembourg Luxembourg 1.86 +17.2% 74
Latvia Latvia 2.41 +5.29% 64
Macao SAR China Macao SAR China 3.47 +131% 50
Moldova Moldova 5.56 -13.8% 30
Madagascar Madagascar 7.6 -5.32% 19
Maldives Maldives 8.35 -11.3% 17
Mexico Mexico 2.08 -0.36% 67
North Macedonia North Macedonia 2.67 -4.38% 61
Malta Malta 3.14 -10.2% 54
Montenegro Montenegro 5.78 -8.67% 29
Mauritius Mauritius 5.31 +7.94% 34
Malawi Malawi 5.1 -7.69% 36
Malaysia Malaysia 1.65 -3.81% 79
Namibia Namibia 5.79 +5.01% 28
Nicaragua Nicaragua 1.52 -1.14% 84
Netherlands Netherlands 1.56 -2.98% 82
Norway Norway 0.373 +36.9% 103
Nepal Nepal 3.78 +54.5% 44
Pakistan Pakistan 6.63 +1.26% 23
Panama Panama 2.57 +1.5% 62
Peru Peru 4.48 +8.84% 40
Philippines Philippines 3.19 +1.66% 53
Papua New Guinea Papua New Guinea 5.42 +13.3% 31
Poland Poland 2.33 -4.36% 65
Paraguay Paraguay 3.01 +2.51% 56
Saudi Arabia Saudi Arabia 1.51 -16% 86
Solomon Islands Solomon Islands 9.39 -1.31% 15
El Salvador El Salvador 1.77 -1.55% 76
San Marino San Marino 21 -60.4% 4
Slovakia Slovakia 1.99 +7.38% 69
Slovenia Slovenia 1.52 -13.4% 85
Sweden Sweden 0.381 +25.3% 102
Eswatini Eswatini 6.87 +3.25% 21
Chad Chad 31.5 +13.7% 2
Thailand Thailand 2.76 -2.93% 60
Tonga Tonga 11.2 +35.4% 13
Trinidad & Tobago Trinidad & Tobago 2.8 -9.59% 59
Turkey Turkey 1.48 -25.2% 88
Uganda Uganda 4.5 -11.9% 39
Ukraine Ukraine 37.4 -2.01% 1
Uruguay Uruguay 1.65 +19% 80
United States United States 0.847 +18.2% 99
Uzbekistan Uzbekistan 3.45 -2.2% 51
St. Vincent & Grenadines St. Vincent & Grenadines 8.11 -19.9% 18
Samoa Samoa 5.37 +7.8% 32
Kosovo Kosovo 1.93 -0.113% 72

                    
# 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 = 'FB.AST.NPER.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 <- 'FB.AST.NPER.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))