Primary income payments (BoP, current US$)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 8,315,386,810 -9.48% 58
Albania Albania 1,244,229,160 +9.61% 83
Argentina Argentina 18,925,274,409 -4.48% 46
Armenia Armenia 1,662,779,506 +12.5% 79
Antigua & Barbuda Antigua & Barbuda 133,960,724 +26.1% 103
Australia Australia 125,338,088,035 -1.08% 15
Austria Austria 48,670,874,184 +11.8% 24
Azerbaijan Azerbaijan 5,328,473,000 +3.1% 65
Belgium Belgium 98,598,274,774 +0.596% 18
Bangladesh Bangladesh 5,095,333,449 +17.7% 66
Bulgaria Bulgaria 9,021,170,000 -7.16% 54
Bahrain Bahrain 8,878,723,404 +17.5% 56
Bahamas Bahamas 921,114,503 -2.96% 88
Bosnia & Herzegovina Bosnia & Herzegovina 1,394,373,035 +12.8% 80
Belarus Belarus 3,432,290,473 -13.4% 74
Belize Belize 151,263,877 +14.6% 102
Brazil Brazil 110,656,629,155 -0.365% 16
Brunei Brunei 508,340,886 -33.4% 93
Bhutan Bhutan 210,806,328 +15.7% 99
Canada Canada 183,075,912,299 +6% 11
Switzerland Switzerland 243,360,815,782 +0.255% 10
Chile Chile 29,114,502,033 +7.74% 35
China China 439,282,819,517 +1.21% 3
Colombia Colombia 23,063,327,777 +2.95% 42
Cape Verde Cape Verde 98,324,180 +42.7% 105
Costa Rica Costa Rica 9,442,167,253 +16.5% 53
Cyprus Cyprus 34,841,903,914 +2.05% 29
Czechia Czechia 32,805,190,129 +3.09% 32
Germany Germany 304,920,258,469 +4.07% 7
Djibouti Djibouti 158,377,655 -15.4% 101
Dominica Dominica 7,860,130 -11.2% 113
Denmark Denmark 35,186,144,398 +8.54% 28
Dominican Republic Dominican Republic 8,151,100,000 +18.8% 59
Ecuador Ecuador 3,629,732,841 +16.8% 73
Spain Spain 136,452,710,167 +12.2% 14
Estonia Estonia 4,280,453,942 +1.63% 68
Finland Finland 31,644,692,905 +3% 33
France France 351,251,040,147 +14.3% 6
United Kingdom United Kingdom 558,340,261,578 -2.25% 2
Georgia Georgia 3,973,602,995 -7.21% 72
Gambia Gambia 26,302,384 -41.7% 110
Greece Greece 16,702,141,374 +9.09% 49
Grenada Grenada 165,125,203 +1.51% 100
Guatemala Guatemala 4,060,524,940 +4.97% 70
Hong Kong SAR China Hong Kong SAR China 243,876,061,136 +7.8% 9
Honduras Honduras 3,393,422,752 +9.71% 75
Croatia Croatia 6,824,040,450 +15.1% 62
Hungary Hungary 38,236,775,095 +2.36% 27
Indonesia Indonesia 45,908,462,905 +4.53% 25
India India 102,965,024,299 +20.5% 17
Iceland Iceland 1,320,296,886 +126% 82
Israel Israel 23,334,700,000 +7.12% 41
Italy Italy 154,321,759,516 +7.91% 13
Jamaica Jamaica 920,143,726 +8.9% 89
Japan Japan 166,769,707,814 +9.09% 12
Kazakhstan Kazakhstan 25,823,219,212 -15.3% 37
Cambodia Cambodia 967,606,096 -32.9% 87
St. Kitts & Nevis St. Kitts & Nevis 57,686,385 +3.39% 108
South Korea South Korea 44,704,400,000 +3.46% 26
Kuwait Kuwait 6,488,611,900 +18.8% 63
St. Lucia St. Lucia 309,485,819 +24.4% 97
Lesotho Lesotho 110,048,145 +6.57% 104
Lithuania Lithuania 5,572,786,951 +1.43% 64
Luxembourg Luxembourg 401,539,915,339 +5.18% 5
Latvia Latvia 3,981,303,586 +0.644% 71
Moldova Moldova 977,030,000 +18.1% 86
Maldives Maldives 797,910,982 -1.72% 91
Mexico Mexico 75,948,148,771 +16.2% 19
North Macedonia North Macedonia 1,122,589,731 +11.1% 84
Malta Malta 23,878,188,978 -2.23% 40
Montenegro Montenegro 541,257,132 +42.7% 92
Mozambique Mozambique 2,922,280,435 +34.5% 76
Malaysia Malaysia 34,295,994,786 +9.53% 30
Namibia Namibia 1,108,025,436 +12.6% 85
Nigeria Nigeria 10,508,681,838 -19.1% 51
Nicaragua Nicaragua 1,366,200,000 +20.4% 81
Netherlands Netherlands 421,087,303,415 +0.426% 4
Norway Norway 51,467,935,215 +1.42% 23
Nepal Nepal 262,429,708 +30.5% 98
New Zealand New Zealand 17,001,186,141 +9.39% 48
Pakistan Pakistan 10,499,000,000 +34% 52
Panama Panama 8,897,779,286 +10.9% 55
Peru Peru 23,048,473,681 +16.1% 43
Philippines Philippines 12,777,389,487 +6.25% 50
Poland Poland 55,932,000,000 +1.71% 21
Portugal Portugal 24,914,181,599 +0.372% 39
Paraguay Paraguay 1,976,396,810 +0.967% 78
Palestinian Territories Palestinian Territories 91,105,641 -28.4% 106
Qatar Qatar 26,654,945,055 +14.6% 36
Romania Romania 19,831,644,257 +5.91% 45
Russia Russia 53,402,480,000 -12.6% 22
Saudi Arabia Saudi Arabia 34,000,619,327 +28.2% 31
Singapore Singapore 288,590,316,063 +12% 8
Solomon Islands Solomon Islands 67,181,056 +64.2% 107
El Salvador El Salvador 2,704,981,316 +4.77% 77
Suriname Suriname 438,847,664 +19.5% 95
Slovakia Slovakia 8,121,541,107 +6.72% 60
Slovenia Slovenia 4,205,245,458 +5.76% 69
Sweden Sweden 69,913,770,639 +8.07% 20
Thailand Thailand 30,719,593,961 +6.4% 34
Tajikistan Tajikistan 471,971,753 +75.1% 94
Timor-Leste Timor-Leste 344,946,348 +8.76% 96
Tonga Tonga 18,206,716 +34.7% 112
Trinidad & Tobago Trinidad & Tobago 891,213,051 +25.6% 90
Turkey Turkey 25,321,000,000 +30.3% 38
Ukraine Ukraine 8,852,000,000 +22.2% 57
Uruguay Uruguay 7,749,273,437 +0.0171% 61
United States United States 1,443,600,000,000 +10.2% 1
Uzbekistan Uzbekistan 4,532,608,182 +4.79% 67
St. Vincent & Grenadines St. Vincent & Grenadines 18,792,622 +108% 111
Vietnam Vietnam 21,235,000,000 -21.4% 44
Samoa Samoa 45,725,701 -0.575% 109
South Africa South Africa 18,591,512,619 +9.58% 47

                    
# 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 = 'BM.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 <- 'BM.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))