PPG, commercial banks (NFL, current US$)

Source: worldbank.org, 03.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Angola Angola -2,786,038,000 +4,657% 80
Albania Albania -34,965,000 +3.58% 59
Argentina Argentina -59,364,000 +2,548% 63
Armenia Armenia -4,150,000 +12.4% 46
Azerbaijan Azerbaijan -321,108,000 +10.6% 72
Benin Benin 594,478,000 +746% 11
Burkina Faso Burkina Faso 30,023,000 -1,832% 23
Bangladesh Bangladesh -25,160,000 -161% 56
Bosnia & Herzegovina Bosnia & Herzegovina -6,803,000 -7.72% 50
Belarus Belarus -8,953,000 +2.64% 52
Belize Belize 0 34
Bolivia Bolivia -9,244,000 +2.56% 53
Brazil Brazil -1,875,111,000 -12.1% 79
Bhutan Bhutan -4,246,000 +2.63% 47
China China 12,166,577,000 -27.6% 1
Côte d’Ivoire Côte d’Ivoire 424,419,000 -81.3% 13
Cameroon Cameroon 3,922,000 -86.1% 29
Congo - Kinshasa Congo - Kinshasa 26,148,000 -779% 24
Congo - Brazzaville Congo - Brazzaville 0 34
Colombia Colombia -1,209,379,000 -157% 77
Cape Verde Cape Verde -27,701,000 +170% 58
Costa Rica Costa Rica -226,078,000 +23.9% 71
Dominica Dominica -1,298,000 +36.8% 40
Dominican Republic Dominican Republic -64,251,000 -6.89% 64
Ecuador Ecuador 598,097,000 -756% 10
Egypt Egypt 2,573,198,000 +7.95% 2
Ethiopia Ethiopia 212,489,000 -149% 15
Gabon Gabon 473,768,000 -869% 12
Georgia Georgia -5,384,000 -67.3% 49
Ghana Ghana 155,597,000 -56.7% 19
Guinea Guinea 178,184,000 +39.4% 17
Gambia Gambia -3,358,000 0% 44
Grenada Grenada 0 34
Guatemala Guatemala -1,680,000 -394% 41
Guyana Guyana -984,000 +6.38% 39
Honduras Honduras -49,584,000 +155% 61
Haiti Haiti -2,326,000 -33.3% 43
Indonesia Indonesia 1,396,809,000 +273% 5
India India 2,549,655,000 +108% 3
Iran Iran 544,000 -98.8% 32
Iraq Iraq -335,870,000 +60.9% 73
Jordan Jordan -10,033,000 +123% 54
Kenya Kenya 187,412,000 -352% 16
Laos Laos -183,923,000 +55.4% 68
Lebanon Lebanon 607,000 +43.8% 31
Liberia Liberia 0 34
Sri Lanka Sri Lanka 48,289,000 -6.84% 22
Lesotho Lesotho -369,000 +73.2% 36
Morocco Morocco -154,768,000 +789% 67
Moldova Moldova -2,065,000 +2.63% 42
Madagascar Madagascar 15,558,000 -189% 27
Maldives Maldives -26,746,000 -130% 57
Mexico Mexico -2,955,564,000 +211% 81
North Macedonia North Macedonia -4,400,000 -102% 48
Myanmar (Burma) Myanmar (Burma) -188,374,000 -14.4% 69
Montenegro Montenegro 19,729,000 -114% 26
Mongolia Mongolia 74,641,000 -22,718% 20
Mozambique Mozambique -113,505,000 +9.89% 65
Mauritius Mauritius 52,399,000 -91.1% 21
Niger Niger -7,728,000 +2.64% 51
Nigeria Nigeria -480,729,000 +115% 74
Nicaragua Nicaragua -753,000 38
Nepal Nepal -256,000 +383% 35
Pakistan Pakistan -1,655,714,000 -50.3% 78
Philippines Philippines -211,214,000 -12.3% 70
Papua New Guinea Papua New Guinea -11,062,000 +39.6% 55
Rwanda Rwanda 247,612,000 +91.3% 14
Sudan Sudan 0 34
Senegal Senegal 846,704,000 +524% 7
El Salvador El Salvador 9,907,000 -1,097% 28
Serbia Serbia 915,991,000 +164% 6
Suriname Suriname -4,147,000 +16.1% 45
Eswatini Eswatini 0 34
Syria Syria 0 34
Togo Togo 23,952,000 -617% 25
Tajikistan Tajikistan 0 34
Turkmenistan Turkmenistan -55,807,000 -357% 62
Tunisia Tunisia 2,535,000 -104% 30
Turkey Turkey 1,997,734,000 -5,263% 4
Tanzania Tanzania 790,699,000 -577% 8
Uganda Uganda 613,323,000 -1,256% 9
Ukraine Ukraine -139,447,000 -125% 66
Uzbekistan Uzbekistan 175,145,000 -61% 18
St. Vincent & Grenadines St. Vincent & Grenadines 281,000 -149% 33
Vietnam Vietnam -733,770,000 +11.7% 76
Kosovo Kosovo -421,000 -186% 37
South Africa South Africa -680,659,000 +5.67% 75
Zambia Zambia -48,226,000 -78.3% 60
Zimbabwe Zimbabwe 0 34

                    
# 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.NFL.PCBK.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.NFL.PCBK.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))