GNI per capita, PPP (constant 2021 international $)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 6,254 -0.334% 69
Argentina Argentina 25,284 -5.34% 29
Armenia Armenia 18,726 +0.264% 37
Australia Australia 58,523 -1.3% 10
Benin Benin 3,823 +5.21% 76
Burkina Faso Burkina Faso 2,569 +9.27% 90
Bangladesh Bangladesh 8,855 +3.3% 62
Bulgaria Bulgaria 32,273 +2.54% 22
Bosnia & Herzegovina Bosnia & Herzegovina 19,913 +3.64% 35
Belarus Belarus 28,074 +4.7% 27
Bermuda Bermuda 110,442 +5.69% 1
Brazil Brazil 18,932 +2.54% 36
Brunei Brunei 80,707 +1.46% 3
Central African Republic Central African Republic 1,180 -1.86% 98
Canada Canada 55,319 -1.51% 11
Chile Chile 28,707 +2.97% 24
Côte d’Ivoire Côte d’Ivoire 6,792 +8.42% 66
Cameroon Cameroon 4,776 -0.507% 74
Congo - Kinshasa Congo - Kinshasa 2,366 +8.89% 92
Colombia Colombia 18,663 +1.5% 38
Comoros Comoros 3,554 +1.48% 79
Cape Verde Cape Verde 10,015 +8.61% 59
Costa Rica Costa Rica 24,653 +3.82% 30
Cyprus Cyprus 47,251 +0.363% 14
Germany Germany 65,408 +0.726% 7
Djibouti Djibouti 6,708 +2.47% 67
Denmark Denmark 72,120 +3.43% 6
Dominican Republic Dominican Republic 23,476 +2.99% 33
Ecuador Ecuador 13,946 -0.059% 47
Egypt Egypt 15,805 -1.11% 44
Ethiopia Ethiopia 3,000 +8.22% 82
Gabon Gabon 17,981 +0.184% 39
Georgia Georgia 24,167 +14.4% 31
Ghana Ghana 6,966 +8.94% 65
Guinea Guinea 3,798 +8.71% 77
Gambia Gambia 2,864 -2.65% 85
Guinea-Bissau Guinea-Bissau 2,699 +2.63% 89
Equatorial Guinea Equatorial Guinea 11,774 -3.56% 55
Guatemala Guatemala 12,682 +4.02% 51
Hong Kong SAR China Hong Kong SAR China 72,526 +5.14% 5
Honduras Honduras 6,183 +4.22% 70
Croatia Croatia 43,089 +5.54% 16
Haiti Haiti 2,985 -3.73% 83
Indonesia Indonesia 13,851 +4% 48
India India 9,744 +3.22% 60
Iraq Iraq 12,195 -3.91% 54
Israel Israel 46,968 +0.53% 15
Italy Italy 52,778 +1.16% 12
Kenya Kenya 5,695 +2.83% 71
Cambodia Cambodia 6,569 +1.06% 68
Libya Libya 12,256 +3.94% 53
Sri Lanka Sri Lanka 13,379 +7.84% 49
Morocco Morocco 8,955 +3.75% 61
Moldova Moldova 17,330 +6.86% 40
Madagascar Madagascar 1,574 +0.362% 95
Mexico Mexico 22,443 +0.205% 34
North Macedonia North Macedonia 23,758 +5.84% 32
Mali Mali 2,855 +2.86% 86
Malta Malta 51,843 +1.36% 13
Montenegro Montenegro 28,425 +2.02% 26
Mongolia Mongolia 16,830 +2.94% 42
Mozambique Mozambique 1,450 +0.347% 97
Malaysia Malaysia 33,000 +3.48% 21
Namibia Namibia 10,709 +3.37% 58
Niger Niger 2,090 +9.8% 93
Nicaragua Nicaragua 7,786 +5.79% 63
Nepal Nepal 5,071 +4.2% 73
Pakistan Pakistan 5,606 +2.46% 72
Peru Peru 15,022 +4.77% 45
Philippines Philippines 11,580 +6.67% 56
Poland Poland 43,044 +3.23% 17
Portugal Portugal 42,037 +3.02% 18
Paraguay Paraguay 14,943 +1.61% 46
Romania Romania 40,954 +3.13% 19
Rwanda Rwanda 3,278 +11.6% 81
Saudi Arabia Saudi Arabia 61,973 -5.94% 9
Sudan Sudan 1,831 -15.3% 94
Senegal Senegal 4,264 +2.74% 75
Singapore Singapore 110,344 +4.08% 2
Sierra Leone Sierra Leone 2,887 -4.83% 84
El Salvador El Salvador 10,826 +1.47% 57
Somalia Somalia 1,460 +2.36% 96
Serbia Serbia 25,763 +4.63% 28
Slovakia Slovakia 38,089 +2.41% 20
Sweden Sweden 65,071 +0.733% 8
Seychelles Seychelles 28,579 +1.43% 25
Chad Chad 2,451 -2.83% 91
Togo Togo 2,777 +2.81% 87
Tunisia Tunisia 12,626 +0.714% 52
Tanzania Tanzania 3,646 +3.05% 78
Uganda Uganda 2,733 +0.912% 88
Ukraine Ukraine 16,973 +2.77% 41
Uruguay Uruguay 28,851 +2.61% 23
United States United States 75,644 +1.63% 4
Samoa Samoa 7,191 +11.6% 64
Kosovo Kosovo 16,174 +16% 43
South Africa South Africa 12,984 -1.1% 50
Zimbabwe Zimbabwe 3,403 +0.281% 80

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