Domestic credit to private sector by banks (% of GDP)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 7.95 -3.56% 129
Albania Albania 31.3 +5.07% 90
United Arab Emirates United Arab Emirates 69.9 +4.08% 29
Argentina Argentina 13.2 +10.8% 122
Armenia Armenia 62.8 +17.3% 39
Antigua & Barbuda Antigua & Barbuda 38.3 +0.638% 72
Australia Australia 130 +1.76% 5
Austria Austria 83.5 -1.3% 20
Azerbaijan Azerbaijan 24.5 +10.8% 103
Belgium Belgium 67.4 -1.45% 34
Benin Benin 19 +1.98% 114
Burkina Faso Burkina Faso 27 -14.5% 98
Bangladesh Bangladesh 35.7 -4.86% 79
Bulgaria Bulgaria 47.5 +5.11% 62
Bosnia & Herzegovina Bosnia & Herzegovina 46.2 +6.3% 66
Belize Belize 37.4 -10.2% 73
Bolivia Bolivia 65.5 -6.26% 37
Brazil Brazil 75.8 +6.7% 26
Brunei Brunei 36.3 +1.12% 76
Bhutan Bhutan 53.2 -25.4% 52
Botswana Botswana 32.8 +9.57% 86
Chile Chile 74.9 -6.21% 27
China China 194 +2.4% 2
Côte d’Ivoire Côte d’Ivoire 22.7 +2.01% 108
Colombia Colombia 39.5 -5.05% 70
Costa Rica Costa Rica 51 +1.75% 55
Cyprus Cyprus 58.6 -6.4% 43
Czechia Czechia 48.3 +0.685% 59
Djibouti Djibouti 23.5 +8.08% 105
Dominica Dominica 39.4 -5.71% 71
Denmark Denmark 142 -2.84% 3
Dominican Republic Dominican Republic 30.9 +3.75% 92
Algeria Algeria 19.4 +3.04% 112
Ecuador Ecuador 54.6 +3.6% 49
Egypt Egypt 27.6 -5.77% 96
Spain Spain 72.5 -5.14% 28
Estonia Estonia 61.1 +5.43% 40
Finland Finland 90.5 -1.53% 17
Fiji Fiji 77.7 +2.89% 24
France France 104 -4.34% 15
United Kingdom United Kingdom 114 -4.91% 13
Georgia Georgia 66.2 +4.47% 36
Guinea-Bissau Guinea-Bissau 10.7 -12% 126
Greece Greece 48.2 -1.49% 61
Grenada Grenada 54.1 +5.08% 50
Guatemala Guatemala 36.3 -0.936% 77
Guyana Guyana 10.4 -18.7% 127
Hong Kong SAR China Hong Kong SAR China 231 -7.12% 1
Honduras Honduras 76.5 +3.35% 25
Croatia Croatia 47.1 -0.0588% 63
Haiti Haiti 3.96 -20.8% 132
Hungary Hungary 32.1 -0.971% 87
Indonesia Indonesia 31.8 +1.6% 89
Ireland Ireland 25.1 -3.31% 102
Iraq Iraq 14 +11.2% 119
Iceland Iceland 90.3 +1.52% 18
Israel Israel 69.7 +0.288% 31
Italy Italy 59.5 -4.41% 41
Jamaica Jamaica 49.7 +1.46% 58
Jordan Jordan 80.1 -2.03% 22
Japan Japan 123 +0.725% 9
Kazakhstan Kazakhstan 25.8 +6.83% 100
Kyrgyzstan Kyrgyzstan 23 +16.3% 106
Cambodia Cambodia 125 -4.22% 7
St. Kitts & Nevis St. Kitts & Nevis 67 +8.74% 35
Kuwait Kuwait 4.4 -4.15% 131
Libya Libya 13.5 +13.4% 120
St. Lucia St. Lucia 50.7 +0.193% 56
Lesotho Lesotho 25.1 +2.58% 101
Lithuania Lithuania 36 +4.6% 78
Luxembourg Luxembourg 85.2 -9.82% 19
Latvia Latvia 29.7 +3.3% 94
Macao SAR China Macao SAR China 128 -12.5% 6
Morocco Morocco 57 -2.3% 47
Moldova Moldova 24.2 +17.2% 104
Madagascar Madagascar 16.4 -2.8% 117
Maldives Maldives 31.9 +0.689% 88
Mexico Mexico 26.6 +5.03% 99
North Macedonia North Macedonia 51.9 +4.32% 54
Mali Mali 22.6 -3.42% 109
Malta Malta 63.5 -2.73% 38
Montenegro Montenegro 46.4 +7.84% 65
Mozambique Mozambique 17.3 -3.62% 115
Mauritius Mauritius 69.8 +0.0778% 30
Malaysia Malaysia 116 -0.854% 11
Namibia Namibia 48.2 -3.35% 60
Niger Niger 10.3 -6.23% 128
Nicaragua Nicaragua 29.1 +8.59% 95
Netherlands Netherlands 81.5 -3.08% 21
Norway Norway 110 +1.37% 14
Nepal Nepal 91.9 +0.622% 16
New Zealand New Zealand 130 +0.0419% 4
Pakistan Pakistan 11.3 -4.69% 125
Panama Panama 68.3 -0.09% 33
Philippines Philippines 49.8 +3.11% 57
Poland Poland 33.7 -2.91% 83
Portugal Portugal 78.3 -3.21% 23
Paraguay Paraguay 57.5 +9.83% 46
Palestinian Territories Palestinian Territories 68.5 +24.5% 32
Qatar Qatar 120 +1.62% 10
Romania Romania 22.7 -1.45% 107
Rwanda Rwanda 22.5 +1.14% 110
Senegal Senegal 29.7 -5.51% 93
Solomon Islands Solomon Islands 19.4 -1.75% 113
Sierra Leone Sierra Leone 3.65 +13.2% 133
El Salvador El Salvador 53.1 +1.31% 53
Somalia Somalia 0.000188 +2.35% 134
Serbia Serbia 33 -0.0927% 85
South Sudan South Sudan 6.64 +28.3% 130
Suriname Suriname 15.9 -4.39% 118
Slovakia Slovakia 59.3 -3.3% 42
Slovenia Slovenia 35.7 -2.04% 80
Sweden Sweden 124 -2.74% 8
Eswatini Eswatini 21.4 +0.467% 111
Seychelles Seychelles 34.6 +9.11% 81
Togo Togo 27.1 -2.49% 97
Thailand Thailand 115 -3.18% 12
Timor-Leste Timor-Leste 34.4 +45.8% 82
Tonga Tonga 41.3 +0.683% 68
Trinidad & Tobago Trinidad & Tobago 46.9 +4.95% 64
Tunisia Tunisia 58.2 -7.16% 44
Turkey Turkey 37 -14.7% 74
Tanzania Tanzania 16.7 +2.33% 116
Uganda Uganda 12.6 -2.75% 123
Ukraine Ukraine 13.4 -2.88% 121
Uruguay Uruguay 31.1 +8.75% 91
United States United States 46.1 -6.08% 67
Uzbekistan Uzbekistan 33.2 -3.37% 84
St. Vincent & Grenadines St. Vincent & Grenadines 36.7 -7.66% 75
Vanuatu Vanuatu 53.5 +2.12% 51
Samoa Samoa 41 -6.93% 69
Kosovo Kosovo 55.9 +10.6% 48
South Africa South Africa 57.6 -0.0412% 45
Zambia Zambia 12.5 -2.52% 124

                    
# 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 = 'FD.AST.PRVT.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 <- 'FD.AST.PRVT.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))