GNI, PPP (constant 2021 international $)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 236,944,522,459 +2.75% 41
Argentina Argentina 1,155,390,265,227 -5.01% 17
Armenia Armenia 56,804,447,118 +2.6% 66
Australia Australia 1,592,104,283,260 +0.74% 11
Benin Benin 55,286,358,351 +7.83% 70
Burkina Faso Burkina Faso 60,499,019,215 +11.8% 64
Bangladesh Bangladesh 1,536,846,536,014 +4.56% 13
Bulgaria Bulgaria 207,977,523,923 +2.51% 44
Bosnia & Herzegovina Bosnia & Herzegovina 63,009,168,010 +2.97% 63
Belarus Belarus 256,424,356,468 +4.19% 37
Bermuda Bermuda 7,138,528,542 +5.59% 92
Brazil Brazil 4,013,632,224,407 +2.95% 4
Brunei Brunei 37,344,815,782 +2.3% 80
Central African Republic Central African Republic 6,287,577,176 +1.54% 93
Canada Canada 2,284,027,958,167 +1.45% 8
Chile Chile 567,389,328,334 +3.53% 24
Côte d’Ivoire Côte d’Ivoire 216,882,249,059 +11.1% 43
Cameroon Cameroon 139,100,098,680 +2.13% 50
Congo - Kinshasa Congo - Kinshasa 258,554,633,174 +12.5% 36
Colombia Colombia 987,036,855,107 +2.6% 18
Comoros Comoros 3,080,192,646 +3.42% 97
Cape Verde Cape Verde 5,256,666,416 +9.14% 95
Costa Rica Costa Rica 126,465,894,989 +4.31% 52
Cyprus Cyprus 44,413,187,175 +1.75% 77
Germany Germany 5,462,317,440,489 +0.257% 3
Djibouti Djibouti 7,840,154,804 +3.87% 91
Denmark Denmark 431,058,517,091 +3.95% 30
Dominican Republic Dominican Republic 268,268,524,993 +3.86% 35
Ecuador Ecuador 252,911,316,747 +0.805% 38
Egypt Egypt 1,841,884,629,418 +0.619% 10
Ethiopia Ethiopia 396,138,443,739 +11.1% 31
Gabon Gabon 45,653,110,757 +2.37% 76
Georgia Georgia 88,787,523,055 +13.1% 58
Ghana Ghana 239,827,722,896 +11% 40
Guinea Guinea 56,035,403,154 +11.3% 69
Gambia Gambia 7,904,515,667 -0.408% 90
Guinea-Bissau Guinea-Bissau 5,941,933,181 +4.92% 94
Equatorial Guinea Equatorial Guinea 22,282,683,452 -1.21% 88
Guatemala Guatemala 233,432,853,573 +5.63% 42
Hong Kong SAR China Hong Kong SAR China 545,696,108,203 +4.97% 26
Honduras Honduras 66,938,885,759 +6% 62
Croatia Croatia 166,594,051,898 +5.72% 47
Haiti Haiti 35,145,724,725 -2.61% 81
Indonesia Indonesia 3,926,730,547,121 +4.85% 5
India India 14,138,031,423,225 +4.15% 2
Iraq Iraq 561,469,710,714 -1.85% 25
Israel Israel 468,478,083,958 +1.81% 28
Italy Italy 3,113,166,395,793 +1.15% 6
Kenya Kenya 321,406,723,798 +4.86% 33
Cambodia Cambodia 115,872,019,678 +2.31% 53
Libya Libya 90,462,440,895 +5.02% 57
Sri Lanka Sri Lanka 293,220,733,196 +7.25% 34
Morocco Morocco 346,309,227,625 +4.78% 32
Moldova Moldova 41,404,972,877 +3.88% 79
Madagascar Madagascar 50,309,940,579 +2.84% 72
Mexico Mexico 2,936,864,828,907 +1.07% 7
North Macedonia North Macedonia 42,579,287,408 +3.78% 78
Mali Mali 69,875,072,250 +5.93% 60
Malta Malta 29,775,750,408 +5.32% 83
Montenegro Montenegro 17,732,543,977 +2.07% 89
Mongolia Mongolia 59,322,716,349 +4.23% 65
Mozambique Mozambique 50,226,285,968 +3.32% 73
Malaysia Malaysia 1,173,387,696,601 +4.75% 16
Namibia Namibia 32,448,376,766 +5.71% 82
Niger Niger 56,487,895,662 +13.5% 68
Nicaragua Nicaragua 53,847,470,314 +7.23% 71
Nepal Nepal 150,358,868,808 +4.05% 49
Pakistan Pakistan 1,408,659,168,119 +4.01% 14
Peru Peru 514,031,675,768 +5.93% 27
Philippines Philippines 1,341,415,561,532 +7.56% 15
Poland Poland 1,573,451,679,830 +2.86% 12
Portugal Portugal 449,868,550,337 +4.22% 29
Paraguay Paraguay 103,545,557,478 +2.87% 54
Romania Romania 780,956,958,309 +3.19% 20
Rwanda Rwanda 46,727,794,789 +14% 75
Saudi Arabia Saudi Arabia 2,187,681,545,352 -1.48% 9
Sudan Sudan 92,373,638,240 -14.6% 56
Senegal Senegal 78,901,503,300 +5.15% 59
Singapore Singapore 666,133,473,989 +6.18% 22
Sierra Leone Sierra Leone 24,950,988,705 -2.79% 86
El Salvador El Salvador 68,614,815,040 +1.93% 61
Somalia Somalia 27,746,611,651 +5.99% 84
Serbia Serbia 169,707,357,914 +4.07% 46
Slovakia Slovakia 206,523,251,901 +2.33% 45
Sweden Sweden 687,777,492,962 +1.05% 21
Seychelles Seychelles 3,468,210,985 +2.77% 96
Chad Chad 49,761,444,744 +2.1% 74
Togo Togo 26,419,757,326 +5.14% 85
Tunisia Tunisia 155,011,181,838 +1.35% 48
Tanzania Tanzania 242,239,588,997 +6.04% 39
Uganda Uganda 136,715,112,319 +3.73% 51
Ukraine Ukraine 600,707,043,588 +3.15% 23
Uruguay Uruguay 97,705,260,304 +2.57% 55
United States United States 25,727,227,794,923 +2.63% 1
Samoa Samoa 1,567,746,675 +12.3% 98
Kosovo Kosovo 24,703,380,513 +5.25% 87
South Africa South Africa 831,044,092,743 +0.146% 19
Zimbabwe Zimbabwe 56,599,313,936 +2.08% 67

                    
# 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 = 'NY.GNP.MKTP.PP.KD'

# 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 <- 'NY.GNP.MKTP.PP.KD'

# 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))