Primary income receipts (BoP, current US$)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 671,276,808 +15% 82
Albania Albania 1,038,002,003 +24.4% 76
Argentina Argentina 6,158,898,071 -2.42% 50
Armenia Armenia 723,726,961 -12.4% 81
Antigua & Barbuda Antigua & Barbuda 24,367,299 +11.9% 110
Australia Australia 71,616,282,052 +13.1% 18
Austria Austria 50,412,457,422 +15.3% 21
Azerbaijan Azerbaijan 2,593,738,000 +31.7% 65
Belgium Belgium 109,948,809,280 +3.43% 15
Bangladesh Bangladesh 592,757,631 +28.3% 86
Bulgaria Bulgaria 3,303,010,000 +12.6% 63
Bahrain Bahrain 5,561,170,213 +12.4% 53
Bahamas Bahamas 100,897,856 +12% 99
Bosnia & Herzegovina Bosnia & Herzegovina 1,306,594,890 +21.3% 71
Belarus Belarus 1,621,150,912 +11.1% 69
Belize Belize 21,331,037 +2.62% 111
Brazil Brazil 35,253,977,914 +11.7% 25
Brunei Brunei 999,282,073 +4.34% 79
Bhutan Bhutan 29,027,226 -19.8% 109
Canada Canada 181,604,812,468 +11.1% 12
Switzerland Switzerland 213,460,475,169 +3.6% 10
Chile Chile 12,114,482,832 -3.96% 40
China China 309,253,890,061 +2.97% 8
Colombia Colombia 9,910,568,396 +10.5% 44
Cape Verde Cape Verde 46,513,635 +19.5% 105
Costa Rica Costa Rica 1,253,307,032 +21.4% 72
Cyprus Cyprus 30,888,044,601 +1.61% 28
Czechia Czechia 18,019,085,866 +8.44% 37
Germany Germany 466,180,015,745 +5.78% 3
Djibouti Djibouti 274,306,279 -5.45% 96
Dominica Dominica 11,410,073 +35.6% 113
Denmark Denmark 49,809,592,612 +13.1% 22
Dominican Republic Dominican Republic 1,428,100,000 +0.161% 70
Ecuador Ecuador 293,141,696 +0.286% 95
Spain Spain 127,617,297,013 +12.2% 14
Estonia Estonia 3,350,179,068 +14.8% 62
Finland Finland 32,820,557,056 +3.92% 26
France France 418,124,697,298 +10.8% 5
United Kingdom United Kingdom 526,318,216,355 +2.37% 2
Georgia Georgia 1,769,505,894 -6.27% 68
Gambia Gambia 108,716,249 +426% 98
Greece Greece 12,034,023,356 +10.3% 41
Grenada Grenada 32,237,230 +34.7% 108
Guatemala Guatemala 2,469,287,700 +27.5% 67
Hong Kong SAR China Hong Kong SAR China 282,417,417,957 +9.25% 9
Honduras Honduras 507,879,697 -0.316% 90
Croatia Croatia 7,170,551,869 +27.3% 49
Hungary Hungary 32,251,148,437 +5.67% 27
Indonesia Indonesia 10,011,654,498 +26.6% 43
India India 50,863,123,157 +34.2% 20
Iceland Iceland 1,244,243,281 +6.89% 73
Israel Israel 18,703,800,000 +0.979% 36
Italy Italy 137,240,881,691 +6.08% 13
Jamaica Jamaica 570,373,597 +2.61% 88
Japan Japan 434,103,315,419 +5.36% 4
Kazakhstan Kazakhstan 5,032,678,102 +30% 56
Cambodia Cambodia 608,783,550 +24.6% 85
St. Kitts & Nevis St. Kitts & Nevis 45,281,399 +17.6% 106
South Korea South Korea 71,323,700,000 +2.68% 19
Kuwait Kuwait 39,578,203,364 +4.87% 24
St. Lucia St. Lucia 57,058,104 +14.9% 103
Lesotho Lesotho 614,845,829 +6.5% 84
Lithuania Lithuania 3,476,993,625 +14.2% 60
Luxembourg Luxembourg 372,657,755,442 +5.23% 7
Latvia Latvia 3,249,845,350 +10.1% 64
Moldova Moldova 1,134,960,000 +3.74% 74
Maldives Maldives 47,826,510 -13.1% 104
Mexico Mexico 21,946,991,563 +1.17% 31
North Macedonia North Macedonia 255,752,296 +23.3% 97
Malta Malta 20,614,470,903 -6.01% 33
Montenegro Montenegro 518,147,058 +14.6% 89
Mozambique Mozambique 401,641,128 +21.3% 93
Malaysia Malaysia 20,749,309,262 +5.01% 32
Namibia Namibia 666,314,200 +64.9% 83
Nigeria Nigeria 3,876,930,313 +58.7% 59
Nicaragua Nicaragua 377,300,000 +14.8% 94
Netherlands Netherlands 403,922,747,113 -1.39% 6
Norway Norway 74,178,527,983 +8.95% 17
Nepal Nepal 967,179,010 +76.5% 80
New Zealand New Zealand 7,872,619,399 +0.772% 48
Pakistan Pakistan 1,020,000,000 +48% 77
Panama Panama 4,259,360,098 +18% 58
Peru Peru 5,669,804,073 +20.2% 51
Philippines Philippines 17,742,892,812 +8.41% 38
Poland Poland 25,051,000,000 +4.47% 29
Portugal Portugal 19,513,669,998 +13% 34
Paraguay Paraguay 482,217,271 +29.9% 91
Palestinian Territories Palestinian Territories 1,001,098,095 -70.2% 78
Qatar Qatar 19,436,813,187 +13.1% 35
Romania Romania 9,674,652,296 +3.69% 45
Russia Russia 24,916,350,000 -27.2% 30
Saudi Arabia Saudi Arabia 40,167,422,455 +17.4% 23
Singapore Singapore 199,600,244,468 +21.2% 11
Solomon Islands Solomon Islands 68,941,845 +4.38% 102
El Salvador El Salvador 448,719,895 +1.33% 92
Suriname Suriname 72,771,153 +55.1% 101
Slovakia Slovakia 5,095,791,894 +4.2% 55
Slovenia Slovenia 3,362,449,888 +2.37% 61
Sweden Sweden 96,684,995,678 +7.79% 16
Thailand Thailand 14,817,801,231 -6.92% 39
Tajikistan Tajikistan 4,927,375,248 +47% 57
Timor-Leste Timor-Leste 576,069,415 +10.9% 87
Tonga Tonga 73,122,717 +14.8% 100
Trinidad & Tobago Trinidad & Tobago 1,082,212,371 -10.9% 75
Turkey Turkey 9,542,000,000 +19.1% 46
Ukraine Ukraine 9,182,000,000 -25.4% 47
Uruguay Uruguay 2,513,255,309 +12% 66
United States United States 1,434,716,000,000 +4.21% 1
Uzbekistan Uzbekistan 5,667,402,983 +6.58% 52
St. Vincent & Grenadines St. Vincent & Grenadines 12,333,424 +9.41% 112
Vietnam Vietnam 5,542,000,000 +21.8% 54
Samoa Samoa 35,342,431 +11.3% 107
South Africa South Africa 10,680,459,606 -9.14% 42

                    
# 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 = 'BX.GSR.FCTY.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 <- 'BX.GSR.FCTY.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))