Households and NPISHs Final consumption expenditure per capita (constant 2015 US$)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 1,307 -2.7% 75
Albania Albania 4,053 +4.67% 38
Argentina Argentina 8,276 -4.57% 19
Armenia Armenia 3,718 +4.36% 42
Australia Australia 33,506 -0.946% 3
Benin Benin 853 +2.48% 82
Burkina Faso Burkina Faso 508 +2.8% 97
Bangladesh Bangladesh 1,322 +4.71% 74
Bulgaria Bulgaria 6,673 +4.25% 24
Bahamas Bahamas 20,957 +2.76% 6
Bosnia & Herzegovina Bosnia & Herzegovina 4,709 +2.73% 33
Belarus Belarus 4,709 +13% 34
Bermuda Bermuda 49,083 +3.19% 1
Brazil Brazil 6,198 +4.34% 27
Brunei Brunei 10,124 +5.09% 15
Botswana Botswana 3,245 +0.222% 50
Central African Republic Central African Republic 540 +15.7% 95
Chile Chile 9,256 +0.506% 16
Côte d’Ivoire Côte d’Ivoire 1,466 +3.76% 70
Cameroon Cameroon 1,116 +1.23% 78
Congo - Kinshasa Congo - Kinshasa 339 -0.188% 100
Congo - Brazzaville Congo - Brazzaville 847 +3.98% 83
Colombia Colombia 5,211 +0.499% 29
Comoros Comoros 1,527 +2.79% 69
Cape Verde Cape Verde 3,387 +4.5% 48
Costa Rica Costa Rica 9,160 +3.46% 17
Cyprus Cyprus 20,663 +2.41% 7
Djibouti Djibouti 2,551 +3.98% 57
Dominican Republic Dominican Republic 6,323 +3.68% 25
Ecuador Ecuador 3,913 -2.13% 40
Egypt Egypt 3,485 +6.17% 47
Ethiopia Ethiopia 674 +7.29% 87
Gabon Gabon 2,233 +0.374% 62
Georgia Georgia 5,116 +12.3% 31
Ghana Ghana 1,730 +2.65% 67
Guinea Guinea 704 +1.83% 85
Gambia Gambia 554 +2.05% 93
Guinea-Bissau Guinea-Bissau 644 -1.18% 90
Equatorial Guinea Equatorial Guinea 3,080 -4.36% 51
Guatemala Guatemala 4,074 +3.98% 37
Hong Kong SAR China Hong Kong SAR China 30,102 -0.413% 4
Honduras Honduras 2,263 +2.6% 61
Croatia Croatia 10,677 +5.43% 13
Haiti Haiti 1,267 -6.25% 76
Indonesia Indonesia 2,445 +4.26% 59
India India 1,429 +6.67% 71
Iran Iran 2,868 +1.48% 53
Iraq Iraq 2,311 +1.81% 60
Kenya Kenya 1,347 +2.06% 72
Cambodia Cambodia 1,335 +1.15% 73
Libya Libya 2,516 +1.25% 58
Sri Lanka Sri Lanka 2,758 +4.58% 55
Macao SAR China Macao SAR China 19,580 +3.65% 8
Morocco Morocco 2,026 +2.61% 64
Moldova Moldova 3,552 +8.18% 44
Madagascar Madagascar 328 +0.132% 101
Mexico Mexico 7,474 +1.94% 22
North Macedonia North Macedonia 4,990 +3.23% 32
Mali Mali 671 +1.11% 89
Malta Malta 16,342 +1.74% 9
Montenegro Montenegro 7,654 +8.69% 20
Mongolia Mongolia 3,295 +11.5% 49
Mozambique Mozambique 418 -8.71% 98
Mauritius Mauritius 7,558 +3.25% 21
Malaysia Malaysia 7,205 +3.83% 23
Namibia Namibia 3,713 +10.8% 43
Niger Niger 381 -0.228% 99
Nicaragua Nicaragua 1,807 +7.19% 66
Nepal Nepal 1,006 +1.22% 79
Pakistan Pakistan 1,569 +4.73% 68
Peru Peru 4,467 +1.65% 35
Philippines Philippines 2,801 +4% 54
Poland Poland 10,290 +3.38% 14
Paraguay Paraguay 4,368 +3.93% 36
Palestinian Territories Palestinian Territories 1,891 -34.1% 65
Romania Romania 9,101 +5.94% 18
Russia Russia 6,211 +5.61% 26
Rwanda Rwanda 769 +1.99% 84
Saudi Arabia Saudi Arabia 11,866 -1.93% 11
Sudan Sudan 519 -16.9% 96
Senegal Senegal 995 +0.634% 80
Singapore Singapore 24,294 +2.76% 5
Sierra Leone Sierra Leone 1,210 +2% 77
El Salvador El Salvador 3,520 +2.75% 46
Somalia Somalia 605 +2.32% 91
Serbia Serbia 5,563 +4.75% 28
Seychelles Seychelles 12,531 +10.1% 10
Chad Chad 546 -2% 94
Togo Togo 672 +3.06% 88
Thailand Thailand 3,920 +4.46% 39
Tunisia Tunisia 3,010 +3.43% 52
Turkey Turkey 11,366 +3.43% 12
Tanzania Tanzania 599 +0.196% 92
Uganda Uganda 691 -2.08% 86
Ukraine Ukraine 2,078 +6.28% 63
United States United States 45,923 +1.76% 2
Uzbekistan Uzbekistan 2,719 +5.36% 56
Samoa Samoa 3,533 +10.1% 45
Kosovo Kosovo 5,126 +16.5% 30
South Africa South Africa 3,835 -0.222% 41
Zimbabwe Zimbabwe 915 +1.16% 81

                    
# 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 = 'NE.CON.PRVT.PC.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 <- 'NE.CON.PRVT.PC.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))