GNI per capita (constant 2015 US$)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 2,537 -0.334% 63
Argentina Argentina 12,244 -5.34% 25
Armenia Armenia 5,119 +0.264% 47
Australia Australia 62,511 -1.3% 4
Benin Benin 1,306 +5.21% 76
Burkina Faso Burkina Faso 825 +9.27% 89
Bangladesh Bangladesh 2,063 +3.3% 70
Bulgaria Bulgaria 10,136 +2.54% 28
Bosnia & Herzegovina Bosnia & Herzegovina 6,744 +3.64% 39
Belarus Belarus 6,820 +4.7% 38
Bermuda Bermuda 121,176 +5.69% 1
Brazil Brazil 9,353 +2.54% 30
Brunei Brunei 31,823 +1.46% 12
Central African Republic Central African Republic 498 -1.86% 94
Canada Canada 44,850 -1.51% 9
Chile Chile 14,975 +2.97% 22
Côte d’Ivoire Côte d’Ivoire 2,368 +8.42% 65
Cameroon Cameroon 1,458 -0.507% 75
Congo - Kinshasa Congo - Kinshasa 1,143 +8.89% 80
Colombia Colombia 7,048 +1.5% 35
Comoros Comoros 1,498 +1.48% 73
Cape Verde Cape Verde 4,747 +8.61% 48
Costa Rica Costa Rica 13,505 +3.82% 24
Cyprus Cyprus 29,300 +0.363% 14
Germany Germany 45,790 +0.726% 8
Djibouti Djibouti 3,247 +2.47% 61
Denmark Denmark 62,962 +3.43% 3
Dominican Republic Dominican Republic 8,743 +2.99% 32
Ecuador Ecuador 6,107 -0.059% 42
Egypt Egypt 3,823 -1.11% 59
Gabon Gabon 9,525 +0.184% 29
Georgia Georgia 6,605 +14.4% 40
Ghana Ghana 2,235 +8.94% 68
Guinea Guinea 1,018 +8.71% 84
Gambia Gambia 712 -2.65% 91
Guinea-Bissau Guinea-Bissau 779 +2.63% 90
Equatorial Guinea Equatorial Guinea 4,137 -3.56% 55
Guatemala Guatemala 4,614 +4.02% 49
Hong Kong SAR China Hong Kong SAR China 49,831 +5.14% 7
Honduras Honduras 2,397 +4.22% 64
Croatia Croatia 17,914 +5.54% 19
Haiti Haiti 1,273 -3.73% 77
Indonesia Indonesia 4,205 +4% 54
India India 2,364 +3.22% 66
Iraq Iraq 5,575 -3.91% 46
Israel Israel 42,262 +0.53% 10
Italy Italy 34,141 +1.16% 11
Kenya Kenya 1,864 +2.83% 71
Cambodia Cambodia 2,186 +1.06% 69
Libya Libya 7,214 +3.94% 34
Sri Lanka Sri Lanka 4,024 +7.84% 57
Morocco Morocco 3,466 +3.75% 60
Moldova Moldova 4,209 +6.86% 52
Madagascar Madagascar 430 +0.362% 96
Mexico Mexico 10,585 +0.205% 27
North Macedonia North Macedonia 6,832 +5.84% 36
Mali Mali 967 +2.86% 86
Malta Malta 29,540 +1.36% 13
Montenegro Montenegro 9,128 +2.02% 31
Mongolia Mongolia 5,774 +2.94% 43
Mozambique Mozambique 590 +0.347% 93
Malaysia Malaysia 11,528 +3.48% 26
Namibia Namibia 4,397 +3.37% 51
Niger Niger 691 +9.8% 92
Nicaragua Nicaragua 2,260 +5.79% 67
Nepal Nepal 1,238 +4.2% 79
Pakistan Pakistan 1,728 +2.46% 72
Peru Peru 6,825 +4.77% 37
Philippines Philippines 4,206 +6.67% 53
Poland Poland 17,329 +3.23% 20
Portugal Portugal 22,699 +3.02% 16
Paraguay Paraguay 6,344 +1.61% 41
Romania Romania 13,691 +3.13% 23
Rwanda Rwanda 1,060 +11.6% 83
Saudi Arabia Saudi Arabia 26,483 -5.94% 15
Senegal Senegal 1,472 +2.74% 74
Singapore Singapore 61,988 +4.08% 5
Sierra Leone Sierra Leone 1,073 -4.83% 82
El Salvador El Salvador 4,113 +1.47% 56
Somalia Somalia 495 +2.36% 95
Serbia Serbia 8,307 +4.63% 33
Slovakia Slovakia 18,169 +2.41% 18
Sweden Sweden 56,419 +0.733% 6
Seychelles Seychelles 16,218 +1.43% 21
Chad Chad 1,012 -2.83% 85
Togo Togo 895 +2.81% 88
Tunisia Tunisia 3,893 +0.714% 58
Tanzania Tanzania 1,121 +3.05% 81
Uganda Uganda 921 +0.912% 87
Ukraine Ukraine 2,885 +2.77% 62
Uruguay Uruguay 18,549 +2.61% 17
United States United States 66,880 +1.63% 2
Samoa Samoa 4,518 +11.6% 50
Kosovo Kosovo 5,745 +16% 45
South Africa South Africa 5,752 -1.1% 44
Zimbabwe Zimbabwe 1,261 +0.281% 78

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