Domestic credit to private sector (% of GDP)

Source: worldbank.org, 01.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 9.14 -4.3% 119
Albania Albania 33.9 +4.65% 78
Argentina Argentina 15.2 -1.28% 111
Armenia Armenia 64.8 +16.5% 36
Antigua & Barbuda Antigua & Barbuda 38.3 +0.638% 66
Australia Australia 130 +1.76% 7
Austria Austria 83.8 -1.29% 22
Azerbaijan Azerbaijan 26.4 +14.1% 95
Belgium Belgium 68.8 -1.71% 32
Benin Benin 19 +2% 106
Burkina Faso Burkina Faso 27 -14.5% 94
Bangladesh Bangladesh 35.8 -4.86% 74
Bulgaria Bulgaria 47.5 +5.1% 58
Bosnia & Herzegovina Bosnia & Herzegovina 50.4 +6.52% 53
Belize Belize 37.6 -10.1% 67
Bolivia Bolivia 65.5 -6.26% 35
Brazil Brazil 75.8 +6.7% 28
Brunei Brunei 37.4 +0.883% 68
Bhutan Bhutan 53.2 -25.4% 50
Botswana Botswana 32.9 +9.55% 82
Chile Chile 103 -5.58% 17
China China 194 +2.4% 4
Côte d’Ivoire Côte d’Ivoire 22.7 +2% 101
Colombia Colombia 39.6 -5.04% 64
Costa Rica Costa Rica 52 +1.65% 51
Cyprus Cyprus 58.7 -6.39% 43
Czechia Czechia 48.3 +0.686% 57
Djibouti Djibouti 23.5 +8.08% 98
Dominica Dominica 39.4 -5.71% 65
Denmark Denmark 142 -2.84% 6
Dominican Republic Dominican Republic 31.9 +3.5% 84
Algeria Algeria 19.4 +3.05% 105
Ecuador Ecuador 56.2 +3.09% 46
Egypt Egypt 27.6 -5.77% 92
Spain Spain 74.3 -5.08% 29
Estonia Estonia 61.1 +5.42% 40
Finland Finland 91.7 -1.72% 19
Fiji Fiji 118 +3.1% 13
France France 108 -4.62% 16
United Kingdom United Kingdom 114 -4.84% 15
Georgia Georgia 68.9 +4.33% 31
Guinea-Bissau Guinea-Bissau 11.1 -11.6% 117
Greece Greece 48.4 -1.5% 56
Grenada Grenada 54.1 +5.08% 49
Guatemala Guatemala 36.8 -0.939% 69
Guyana Guyana 14.8 -25.5% 112
Hong Kong SAR China Hong Kong SAR China 231 -7.12% 1
Honduras Honduras 78.2 +3.43% 26
Croatia Croatia 47.1 -0.0513% 59
Haiti Haiti 4.11 -20.4% 120
Hungary Hungary 32.4 -1.04% 83
Indonesia Indonesia 36.4 +1.05% 71
Ireland Ireland 25.1 -3.31% 97
Iraq Iraq 14 +11.2% 114
Iceland Iceland 90.3 +1.52% 20
Italy Italy 60.6 -4.54% 41
Jamaica Jamaica 49.9 +1.44% 54
Jordan Jordan 80.2 -2.03% 24
Japan Japan 197 +0.844% 3
Kazakhstan Kazakhstan 27.6 +5.85% 91
Kyrgyzstan Kyrgyzstan 23.2 +16.1% 99
Cambodia Cambodia 125 -4.2% 10
St. Kitts & Nevis St. Kitts & Nevis 67 +8.74% 34
Libya Libya 13.6 +13.7% 115
St. Lucia St. Lucia 50.7 +0.193% 52
Lesotho Lesotho 25.6 +2.88% 96
Lithuania Lithuania 36 +4.6% 73
Luxembourg Luxembourg 85.2 -9.82% 21
Latvia Latvia 29.7 +3.3% 89
Macao SAR China Macao SAR China 128 -12.5% 9
Moldova Moldova 29.3 +14.7% 90
Madagascar Madagascar 16.6 -2.73% 109
Maldives Maldives 36.1 +0.376% 72
Mexico Mexico 34.7 +4.26% 76
North Macedonia North Macedonia 54.8 +4.67% 47
Mali Mali 22.6 -3.39% 103
Malta Malta 63.6 -2.73% 37
Montenegro Montenegro 46.4 +7.84% 61
Mozambique Mozambique 17.9 -3.41% 107
Mauritius Mauritius 69.8 +0.0673% 30
Malaysia Malaysia 116 -0.854% 14
Niger Niger 10.4 -6.19% 118
Nicaragua Nicaragua 29.7 -0.921% 87
Netherlands Netherlands 81.5 -3.08% 23
Norway Norway 129 +1.1% 8
Nepal Nepal 92.1 +0.605% 18
Pakistan Pakistan 11.4 -4.66% 116
Philippines Philippines 49.8 +3.11% 55
Poland Poland 33.7 -2.91% 79
Portugal Portugal 78.4 -3.2% 25
Paraguay Paraguay 57.5 +9.81% 45
Palestinian Territories Palestinian Territories 68.5 +24.5% 33
Qatar Qatar 120 +1.65% 12
Romania Romania 22.7 -1.45% 100
Rwanda Rwanda 22.6 +1.14% 102
Senegal Senegal 29.7 -5.49% 88
Solomon Islands Solomon Islands 30.3 -3.94% 86
Sierra Leone Sierra Leone 3.66 +13.2% 121
El Salvador El Salvador 62.5 +0.948% 38
Somalia Somalia 0.000188 +2.3% 122
Serbia Serbia 33 -0.111% 81
Suriname Suriname 15.9 -4.41% 110
Slovakia Slovakia 59.3 -3.29% 42
Slovenia Slovenia 35.7 -2.04% 75
Sweden Sweden 124 -2.74% 11
Eswatini Eswatini 21.5 +0.416% 104
Togo Togo 27.2 -2.43% 93
Thailand Thailand 148 -3.98% 5
Timor-Leste Timor-Leste 34.5 +45.7% 77
Tonga Tonga 41.7 +0.577% 63
Trinidad & Tobago Trinidad & Tobago 46.9 +4.93% 60
Tunisia Tunisia 58.3 -7.15% 44
Turkey Turkey 44.2 -11.4% 62
Tanzania Tanzania 16.8 +2.25% 108
Uganda Uganda 14.4 -2.99% 113
Uruguay Uruguay 31.1 +8.76% 85
United States United States 198 +2.79% 2
Uzbekistan Uzbekistan 33.2 -3.37% 80
St. Vincent & Grenadines St. Vincent & Grenadines 36.7 -7.66% 70
Vanuatu Vanuatu 54.2 +2.22% 48
Samoa Samoa 77 -6.76% 27
Kosovo Kosovo 61.3 +10.9% 39

                    
# 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 = 'FS.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 <- 'FS.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))