GNI (current US$)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 73,810,626,291 -3.91% 79
Albania Albania 26,971,002,323 +16% 108
Andorra Andorra 4,213,892,003 +7.55% 154
United Arab Emirates United Arab Emirates 538,118,110,245 +3.89% 24
Argentina Argentina 620,500,316,196 -1.93% 23
Armenia Armenia 24,847,533,404 +6.03% 112
Antigua & Barbuda Antigua & Barbuda 2,122,414,815 +11% 164
Australia Australia 1,693,341,471,506 +2.4% 14
Austria Austria 523,384,071,788 +2.24% 26
Azerbaijan Azerbaijan 71,581,147,353 +3.22% 82
Burundi Burundi 2,172,597,332 -18% 162
Belgium Belgium 675,914,715,993 +3.42% 21
Benin Benin 21,280,255,371 +9.3% 116
Burkina Faso Burkina Faso 22,241,127,444 +14.1% 115
Bangladesh Bangladesh 469,502,745,314 +3.22% 30
Bulgaria Bulgaria 106,859,640,848 +9.73% 65
Bahrain Bahrain 45,181,298,275 +3.66% 94
Bosnia & Herzegovina Bosnia & Herzegovina 28,254,442,056 +2.99% 107
Belarus Belarus 74,150,765,472 +5.73% 78
Belize Belize 3,385,850,479 +14.6% 156
Bermuda Bermuda 9,331,527,171 +6.54% 144
Bolivia Bolivia 48,305,776,845 +10.1% 91
Brazil Brazil 2,112,480,929,980 -0.43% 11
Barbados Barbados 6,871,000,000 +6.47% 148
Brunei Brunei 15,953,749,880 +4.35% 133
Botswana Botswana 19,433,947,940 -0.0292% 122
Central African Republic Central African Republic 2,917,116,979 +7.78% 157
Canada Canada 2,207,194,978,963 +3.37% 9
Switzerland Switzerland 906,663,857,436 +4.56% 19
Chile Chile 313,267,567,597 -2.42% 44
China China 18,613,041,683,553 +2.72% 2
Côte d’Ivoire Côte d’Ivoire 83,064,980,538 +8.49% 72
Cameroon Cameroon 50,405,837,282 +4.34% 89
Congo - Kinshasa Congo - Kinshasa 68,395,859,280 +5.37% 83
Congo - Brazzaville Congo - Brazzaville 14,986,372,643 +3.02% 136
Colombia Colombia 410,056,447,477 +14.9% 37
Comoros Comoros 1,553,984,522 +8.07% 168
Cape Verde Cape Verde 2,715,702,225 +8.22% 158
Costa Rica Costa Rica 88,413,217,230 +9.86% 69
Cyprus Cyprus 32,431,140,071 +5.83% 103
Czechia Czechia 330,064,048,356 -2.43% 43
Germany Germany 4,826,329,098,254 +3.03% 3
Djibouti Djibouti 4,123,896,920 +2.58% 155
Dominica Dominica 691,540,741 +4.96% 175
Denmark Denmark 444,168,431,957 +6.09% 34
Dominican Republic Dominican Republic 117,559,245,601 +2.21% 62
Algeria Algeria 258,580,304,855 +5.96% 50
Ecuador Ecuador 121,339,483,500 +2.54% 61
Egypt Egypt 371,522,711,004 -1.87% 41
Spain Spain 1,713,909,497,043 +6.3% 13
Estonia Estonia 41,834,654,295 +4.59% 99
Finland Finland 301,012,575,489 +1.58% 46
Fiji Fiji 5,419,660,300 +5.64% 150
France France 3,228,952,620,812 +3.86% 7
Micronesia (Federated States of) Micronesia (Federated States of) 508,725,099 +4.21% 176
Gabon Gabon 18,960,197,946 +3.01% 124
United Kingdom United Kingdom 3,611,812,143,560 +7.68% 6
Georgia Georgia 31,581,497,729 +11.2% 104
Ghana Ghana 79,746,122,726 +5.75% 75
Guinea Guinea 23,228,045,823 +13.4% 114
Gambia Gambia 2,475,519,958 +4.27% 160
Guinea-Bissau Guinea-Bissau 2,135,549,657 +2.19% 163
Equatorial Guinea Equatorial Guinea 8,957,199,403 +3.17% 145
Greece Greece 251,437,708,086 +6.6% 51
Grenada Grenada 1,258,535,993 +6.19% 170
Guatemala Guatemala 111,608,348,867 +8.95% 64
Guyana Guyana 16,260,889,826 +20.5% 132
Hong Kong SAR China Hong Kong SAR China 445,652,668,375 +7.82% 33
Honduras Honduras 34,191,018,111 +7.66% 100
Croatia Croatia 92,885,913,973 +10.4% 68
Haiti Haiti 25,227,774,905 +27.1% 111
Hungary Hungary 217,101,887,068 +4.65% 53
Indonesia Indonesia 1,359,439,626,672 +1.84% 15
India India 3,856,153,103,605 +7.45% 5
Ireland Ireland 437,813,266,423 +4.26% 35
Iran Iran 436,292,217,031 +8.09% 36
Iraq Iraq 281,334,457,615 +4.25% 47
Iceland Iceland 33,386,219,956 +4.24% 101
Israel Israel 536,145,100,388 +5.28% 25
Italy Italy 2,357,609,423,284 +2.84% 8
Jamaica Jamaica 19,504,364,078 +1.93% 121
Jordan Jordan 52,106,345,915 +2.75% 87
Japan Japan 4,293,544,428,751 -3.81% 4
Kazakhstan Kazakhstan 267,615,597,120 +13.8% 49
Kenya Kenya 122,557,460,023 +15.5% 60
Kyrgyzstan Kyrgyzstan 16,881,966,480 +12.6% 129
Cambodia Cambodia 45,492,704,837 +9.93% 93
Kiribati Kiribati 497,916,646 +4.68% 177
St. Kitts & Nevis St. Kitts & Nevis 1,054,281,481 +1.43% 172
Kuwait Kuwait 193,826,375,471 -1.94% 55
Laos Laos 15,455,804,356 +5.24% 135
Liberia Liberia 4,429,000,000 +7.58% 152
Libya Libya 46,941,963,177 +3.6% 92
St. Lucia St. Lucia 2,326,414,815 +4.27% 161
Sri Lanka Sri Lanka 96,498,244,044 +18.9% 67
Lesotho Lesotho 2,713,295,098 +5.32% 159
Lithuania Lithuania 82,773,422,187 +7.01% 73
Luxembourg Luxembourg 66,130,199,499 +8.81% 84
Latvia Latvia 42,788,229,827 +3.74% 98
Morocco Morocco 152,047,662,720 +6.81% 58
Moldova Moldova 18,358,278,780 +8.13% 127
Madagascar Madagascar 16,968,506,097 +9.3% 128
Maldives Maldives 6,210,358,219 +6.45% 149
Mexico Mexico 1,797,561,997,730 +2.77% 12
Marshall Islands Marshall Islands 332,401,831 +7.3% 178
North Macedonia North Macedonia 15,818,396,497 +5.73% 134
Mali Mali 25,818,132,693 +8.95% 110
Malta Malta 20,890,952,766 +8.77% 118
Myanmar (Burma) Myanmar (Burma) 73,152,772,652 +11.7% 80
Montenegro Montenegro 8,046,492,032 +5.83% 146
Mongolia Mongolia 20,904,705,330 +15.5% 117
Mozambique Mozambique 19,900,380,278 +4.1% 120
Mauritania Mauritania 10,662,438,410 +0.0202% 141
Mauritius Mauritius 16,534,102,630 +7.1% 131
Malawi Malawi 10,620,512,202 -14% 142
Malaysia Malaysia 408,536,168,719 +5.27% 38
Namibia Namibia 12,926,605,086 +9.41% 138
Niger Niger 19,295,203,170 +16.9% 123
Nigeria Nigeria 181,127,703,101 -48.7% 57
Nicaragua Nicaragua 18,705,082,970 +10% 125
Netherlands Netherlands 1,210,379,369,014 +5.74% 18
Norway Norway 506,437,990,984 -0.277% 29
Nepal Nepal 43,618,588,469 +5.03% 96
Nauru Nauru 259,739,232 +0.00329% 179
New Zealand New Zealand 251,106,754,781 +1.91% 52
Oman Oman 99,699,911,983 -0.972% 66
Pakistan Pakistan 364,085,855,732 +9.62% 42
Panama Panama 81,857,899,200 +3.24% 74
Peru Peru 272,490,769,750 +7.84% 48
Philippines Philippines 521,766,436,503 +7.59% 27
Papua New Guinea Papua New Guinea 30,688,820,937 +7.6% 106
Poland Poland 883,890,681,808 +13.1% 20
Puerto Rico Puerto Rico 85,627,300,000 +4.51% 70
Portugal Portugal 303,014,547,763 +7.45% 45
Paraguay Paraguay 42,963,938,860 +3.45% 97
Palestinian Territories Palestinian Territories 16,647,347,010 -22.7% 130
Qatar Qatar 210,764,835,165 +1.85% 54
Romania Romania 372,615,856,298 +8.92% 40
Russia Russia 2,145,349,984,519 +4.92% 10
Rwanda Rwanda 13,900,791,731 -1.07% 137
Saudi Arabia Saudi Arabia 1,243,696,766,667 +1.42% 17
Sudan Sudan 48,505,122,019 +24.6% 90
Senegal Senegal 31,287,041,736 +5.47% 105
Singapore Singapore 458,396,552,098 +11.1% 32
Solomon Islands Solomon Islands 1,762,426,119 +4.53% 167
Sierra Leone Sierra Leone 7,484,823,279 +17.7% 147
El Salvador El Salvador 33,108,710,000 +4.39% 102
Somalia Somalia 12,061,515,110 +10.4% 139
Serbia Serbia 83,510,525,682 +8.31% 71
São Tomé & Príncipe São Tomé & Príncipe 763,574,043 +11.4% 174
Suriname Suriname 4,348,051,311 +38.7% 153
Slovakia Slovakia 138,571,512,729 +5.7% 59
Slovenia Slovenia 71,642,214,457 +4.59% 81
Sweden Sweden 636,906,562,951 +4.32% 22
Eswatini Eswatini 4,462,800,852 +3.89% 151
Seychelles Seychelles 2,098,309,407 -1.4% 165
Chad Chad 20,414,503,516 +7.93% 119
Togo Togo 9,948,349,383 +8.23% 143
Thailand Thailand 511,688,116,958 +1.73% 28
Tajikistan Tajikistan 18,658,837,499 +22.2% 126
Turkmenistan Turkmenistan 63,650,513,923 +5.86% 85
Timor-Leste Timor-Leste 1,930,794,786 -20.7% 166
Trinidad & Tobago Trinidad & Tobago 26,619,963,758 +2.41% 109
Tunisia Tunisia 52,072,149,801 +10.8% 88
Turkey Turkey 1,307,475,808,059 +18.1% 16
Tanzania Tanzania 76,807,849,019 -0.961% 76
Uganda Uganda 52,360,933,816 +10.1% 86
Ukraine Ukraine 191,071,263,732 +2.57% 56
Uruguay Uruguay 75,725,492,946 +4.47% 77
United States United States 29,243,108,000,000 +5.11% 1
Uzbekistan Uzbekistan 116,100,088,267 +12% 63
St. Vincent & Grenadines St. Vincent & Grenadines 1,147,018,519 +6.75% 171
Vietnam Vietnam 460,695,230,307 +12% 31
Vanuatu Vanuatu 1,327,483,807 +3.63% 169
Samoa Samoa 1,051,479,651 +13.7% 173
Kosovo Kosovo 11,384,703,045 +6.57% 140
South Africa South Africa 392,352,670,971 +4.48% 39
Zambia Zambia 24,621,072,823 -6.28% 113
Zimbabwe Zimbabwe 43,678,673,883 +25.5% 95

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