Net secondary income (BoP, current US$)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola -287,430,469 -40.7% 74
Albania Albania 1,408,216,906 +8.81% 38
Argentina Argentina 2,150,921,489 +13.2% 31
Armenia Armenia 410,669,376 +42.1% 50
Antigua & Barbuda Antigua & Barbuda -103,091,227 +4.49% 71
Australia Australia -503,331,287 -54.6% 79
Austria Austria -3,997,511,782 +10.1% 95
Azerbaijan Azerbaijan 631,744,000 -40.3% 45
Belgium Belgium -11,458,480,660 +29.1% 103
Bangladesh Bangladesh 27,484,390,860 +21.9% 5
Bulgaria Bulgaria 1,072,470,000 -34.2% 41
Bahrain Bahrain -2,659,574,468 -0.14% 91
Bahamas Bahamas 65,425,497 +25.2% 63
Bosnia & Herzegovina Bosnia & Herzegovina 2,972,906,399 +7.56% 27
Belarus Belarus 1,179,468,416 +2.86% 39
Belize Belize 162,090,758 +26.1% 56
Brazil Brazil 2,925,294,288 +14.4% 28
Brunei Brunei -633,685,082 -15.2% 82
Bhutan Bhutan 80,603,861 -5.3% 60
Canada Canada -2,930,716,576 -50% 92
Switzerland Switzerland -15,442,491,339 +13% 106
Chile Chile 263,686,257 -64.2% 52
China China 14,990,125,928 +30.4% 11
Colombia Colombia 15,507,110,547 +20% 9
Cape Verde Cape Verde 467,877,377 +11% 48
Costa Rica Costa Rica 587,352,829 +4.08% 46
Cyprus Cyprus -413,476,554 -8.96% 77
Czechia Czechia -1,685,043,361 -24.8% 86
Germany Germany -69,002,465,799 -5.56% 112
Djibouti Djibouti 9,296,588 -15.1% 67
Dominica Dominica 11,110,099 +116% 66
Denmark Denmark -5,173,017,110 +9.3% 97
Dominican Republic Dominican Republic 10,137,100,000 +4.73% 14
Ecuador Ecuador 5,920,705,688 +24.2% 21
Spain Spain -12,838,878,236 +0.0155% 104
Estonia Estonia 178,469,179 -18.7% 55
Finland Finland -2,135,760,238 -36.5% 88
France France -51,179,781,368 -9.52% 110
United Kingdom United Kingdom -23,388,023,259 -6.56% 108
Georgia Georgia 3,305,765,709 -0.692% 25
Gambia Gambia 554,031,521 +2.59% 47
Greece Greece 2,253,984,089 +60% 30
Grenada Grenada -6,244,241 -27.2% 68
Guatemala Guatemala 22,503,262,430 +7.89% 7
Hong Kong SAR China Hong Kong SAR China -2,584,733,537 +18.2% 90
Honduras Honduras 10,057,107,050 +7.71% 15
Croatia Croatia 1,861,392,752 -30.4% 32
Hungary Hungary -1,366,695,669 -39.4% 85
Indonesia Indonesia 5,977,191,442 +11.1% 20
India India 120,708,302,440 +18.4% 1
Iceland Iceland -387,008,739 +7.46% 75
Israel Israel 8,533,600,000 +11.4% 17
Italy Italy -17,775,907,494 +0.0918% 107
Jamaica Jamaica 3,429,351,095 -0.564% 24
Japan Japan -30,476,316,595 +2.75% 109
Kazakhstan Kazakhstan -574,104,682 -44.6% 80
Cambodia Cambodia 3,197,699,009 +0.75% 26
St. Kitts & Nevis St. Kitts & Nevis -18,273,014 +17.8% 69
South Korea South Korea -4,001,700,000 -6.09% 96
Kuwait Kuwait -14,575,875,832 +12.7% 105
St. Lucia St. Lucia 34,072,935 +0.607% 64
Lesotho Lesotho 679,294,126 +20.1% 44
Lithuania Lithuania -208,014,563 -201% 73
Luxembourg Luxembourg -412,327,370 -58.2% 76
Latvia Latvia 925,413,557 +0.523% 42
Moldova Moldova 1,626,190,000 -10.4% 35
Maldives Maldives -574,589,981 +6.66% 81
Mexico Mexico 64,283,933,672 +1.96% 2
North Macedonia North Macedonia 2,691,116,845 -7.74% 29
Malta Malta -93,189,955 -1.53% 70
Montenegro Montenegro 466,200,392 -1.56% 49
Mozambique Mozambique 1,151,901,773 -18.3% 40
Malaysia Malaysia -2,001,514,605 -23.7% 87
Namibia Namibia 1,699,167,906 +21.3% 34
Nigeria Nigeria 24,041,406,547 +8.66% 6
Nicaragua Nicaragua 5,109,100,000 +12.5% 22
Netherlands Netherlands -9,324,569,385 +68.3% 100
Norway Norway -6,937,879,577 -13.3% 98
Nepal Nepal 15,281,622,963 +33.8% 10
New Zealand New Zealand -648,038,143 -1,525% 83
Pakistan Pakistan 36,803,000,000 +31.6% 3
Panama Panama -178,725,595 +25.4% 72
Peru Peru 7,603,732,791 +11.5% 19
Philippines Philippines 31,684,851,047 +1.8% 4
Poland Poland -3,964,000,000 +77.8% 94
Portugal Portugal 4,850,055,708 -0.0595% 23
Paraguay Paraguay 809,611,005 +19.7% 43
Palestinian Territories Palestinian Territories 1,570,416,108 -24.9% 36
Qatar Qatar -10,189,010,989 -27.3% 101
Romania Romania 1,491,507,664 -20.4% 37
Russia Russia -3,053,870,000 -67.1% 93
Saudi Arabia Saudi Arabia -55,737,216,237 +8.44% 111
Singapore Singapore -7,571,581,810 +11.2% 99
Solomon Islands Solomon Islands 146,259,809 +8.94% 59
El Salvador El Salvador 8,391,945,989 +2.64% 18
Suriname Suriname 153,166,411 +10.3% 58
Slovakia Slovakia -933,980,112 +24.4% 84
Slovenia Slovenia -502,251,353 -11.4% 78
Sweden Sweden -10,822,369,460 +16.1% 102
Thailand Thailand 9,219,190,993 -7.07% 16
Tajikistan Tajikistan 1,720,960,701 +29.7% 33
Timor-Leste Timor-Leste 158,398,937 +80.6% 57
Tonga Tonga 197,295,302 -5.08% 54
Trinidad & Tobago Trinidad & Tobago 29,669,232 -74.7% 65
Turkey Turkey 72,000,000 -87.1% 61
Ukraine Ukraine 21,832,000,000 -6.08% 8
Uruguay Uruguay 202,751,321 +14.5% 53
United States United States -206,897,000,000 +10.3% 113
Uzbekistan Uzbekistan 10,578,217,988 +20.1% 13
St. Vincent & Grenadines St. Vincent & Grenadines 65,867,009 +7.84% 62
Vietnam Vietnam 13,029,000,000 -0.199% 12
Samoa Samoa 281,018,377 +4.47% 51
South Africa South Africa -2,512,082,797 +16.9% 89

                    
# 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 = 'BN.TRF.CURR.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 <- 'BN.TRF.CURR.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))