PPG, IBRD (DOD, current US$)

Source: worldbank.org, 03.09.2025

Year: 2004

Flag Country Value Value change, % Rank
Argentina Argentina 7,446,990,000 -0.813% 5
Armenia Armenia 7,584,000 -3.3% 54
Bangladesh Bangladesh 0 -100% 63
Bosnia & Herzegovina Bosnia & Herzegovina 527,009,000 -2.43% 21
Belarus Belarus 73,031,000 -12.7% 40
Belize Belize 39,981,000 -4.16% 43
Bolivia Bolivia 150,000 62
Brazil Brazil 8,668,375,000 +0.934% 4
Botswana Botswana 3,424,000 -30.9% 56
China China 11,034,761,000 +3.55% 1
Côte d’Ivoire Côte d’Ivoire 478,786,000 -0.422% 24
Cameroon Cameroon 117,000,000 -19.5% 38
Congo - Brazzaville Congo - Brazzaville 0 -100% 63
Colombia Colombia 3,489,727,000 +7.68% 8
Costa Rica Costa Rica 70,705,000 -11.2% 41
Dominica Dominica 4,092,000 +0.0978% 55
Dominican Republic Dominican Republic 378,861,000 +8.39% 29
Algeria Algeria 909,342,000 -13.9% 19
Ecuador Ecuador 834,510,000 -6.02% 20
Egypt Egypt 502,999,000 -6.69% 22
Fiji Fiji 9,258,000 -16.8% 52
Gabon Gabon 38,194,000 -21.6% 44
Ghana Ghana 2,466,000 -36.6% 57
Grenada Grenada 7,819,000 +22.9% 53
Guatemala Guatemala 477,760,000 +11.7% 25
Guyana Guyana 0 -100% 63
Honduras Honduras 69,662,000 -17.8% 42
Indonesia Indonesia 8,943,072,000 -8.55% 3
India India 4,662,452,000 +19.4% 7
Iran Iran 315,996,000 -9.79% 31
Jamaica Jamaica 439,102,000 -7.74% 27
Jordan Jordan 971,136,000 -4.51% 18
Kazakhstan Kazakhstan 1,274,897,000 +0.78% 16
Kenya Kenya 1,114,000 -81% 58
St. Kitts & Nevis St. Kitts & Nevis 13,196,000 +11% 50
Lebanon Lebanon 387,149,000 +7.08% 28
Liberia Liberia 161,570,000 +6.07% 37
St. Lucia St. Lucia 10,510,000 +3.62% 51
Sri Lanka Sri Lanka 1,030,000 -65.4% 59
Lesotho Lesotho 16,196,000 -12.8% 49
Morocco Morocco 2,580,993,000 -5.08% 11
Moldova Moldova 184,684,000 -2.69% 36
Mexico Mexico 9,566,670,000 -10.7% 2
North Macedonia North Macedonia 217,759,000 +24.7% 35
Mauritius Mauritius 77,296,000 -9.55% 39
Malawi Malawi 260,000 -64.9% 61
Nigeria Nigeria 1,027,073,000 -14.5% 17
Pakistan Pakistan 2,459,738,000 -8.72% 13
Peru Peru 2,834,302,000 +1.62% 10
Philippines Philippines 3,316,956,000 -3.72% 9
Papua New Guinea Papua New Guinea 260,234,000 -3.24% 33
Paraguay Paraguay 246,050,000 -3.83% 34
El Salvador El Salvador 347,765,000 -6.53% 30
Serbia Serbia 2,470,201,000 +8.93% 12
Eswatini Eswatini 23,657,000 +59.4% 47
Syria Syria 0 -100% 63
Chad Chad 36,824,000 +19.2% 45
Thailand Thailand 483,437,000 -77% 23
Turkmenistan Turkmenistan 31,167,000 +4.83% 46
Tunisia Tunisia 1,823,701,000 +2.49% 15
Turkey Turkey 6,152,862,000 +18% 6
Tanzania Tanzania 0 -100% 63
Ukraine Ukraine 2,168,152,000 -4.53% 14
Uzbekistan Uzbekistan 311,595,000 +4.47% 32
St. Vincent & Grenadines St. Vincent & Grenadines 948,000 +62.1% 60
South Africa South Africa 22,594,000 +44.5% 48
Zambia Zambia 0 -100% 63
Zimbabwe Zimbabwe 466,859,000 +2.99% 26

                    
# 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.DOD.MIBR.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.DOD.MIBR.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))