Net secondary income (Net current transfers from abroad) (current US$)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola -248,628,061 -45.3% 100
Albania Albania 1,407,979,810 +8.83% 45
Andorra Andorra -50,490,853 +6.68% 97
Argentina Argentina 2,150,921,489 +14.5% 37
Armenia Armenia 410,669,376 +42.1% 71
Antigua & Barbuda Antigua & Barbuda -101,900,000 +18.9% 98
Australia Australia -1,041,747,251 -0.141% 105
Azerbaijan Azerbaijan 631,744,000 -49.9% 62
Bangladesh Bangladesh 686,697,845 -19.4% 58
Bulgaria Bulgaria 1,074,001,900 -33.2% 50
Bosnia & Herzegovina Bosnia & Herzegovina 2,973,600,603 +7.63% 33
Belarus Belarus 1,179,500,000 +2.19% 47
Belize Belize 162,090,750 +26.1% 81
Brazil Brazil 2,637,325,594 +17% 35
Barbados Barbados 122,000,000 -6,200% 85
Brunei Brunei -632,697,811 -15.3% 103
Canada Canada -2,689,578,072 -54.3% 109
Chile Chile 375,808,249 -55.9% 74
China China 14,840,616,893 +29.2% 9
Côte d’Ivoire Côte d’Ivoire -239,137,667 -5.26% 99
Cameroon Cameroon 818,840,357 -8.16% 54
Congo - Kinshasa Congo - Kinshasa 1,346,036,696 -40% 46
Colombia Colombia 15,536,144,997 +20.5% 8
Cape Verde Cape Verde 468,247,199 +11.2% 67
Costa Rica Costa Rica 589,060,445 +0.596% 64
Germany Germany -64,029,299,009 +7.35% 119
Dominica Dominica 7,111,111 +38.1% 93
Denmark Denmark -5,216,636,006 +10.5% 112
Dominican Republic Dominican Republic 10,137,100,057 +4.73% 14
Ecuador Ecuador 5,920,705,700 +24.2% 23
Egypt Egypt 21,949,200,000 +0.495% 6
Fiji Fiji 657,256,730 +17.8% 59
Micronesia (Federated States of) Micronesia (Federated States of) 162,800,000 +4.4% 80
Georgia Georgia 3,291,125,820 -1.2% 31
Guinea Guinea 955,151,683 +65.7% 51
Gambia Gambia 570,000,000 +2.9% 66
Guinea-Bissau Guinea-Bissau 152,381,108 +12.5% 83
Grenada Grenada -6,300,000 -25.9% 94
Guatemala Guatemala 22,503,260,975 +7.89% 5
Guyana Guyana 892,250,000 -23.8% 53
Hong Kong SAR China Hong Kong SAR China -2,584,371,039 +18.2% 108
Honduras Honduras 10,057,100,177 +7.71% 15
Croatia Croatia 1,861,427,924 -23.9% 38
Haiti Haiti 3,771,000,000 +7.08% 29
Indonesia Indonesia 5,977,190,000 +11.1% 22
India India 113,305,685,189 +6.21% 1
Iraq Iraq 357,400,000 -50.9% 75
Israel Israel 8,632,735,186 -17.4% 17
Italy Italy -17,765,110,634 +0.121% 117
Jordan Jordan 5,831,690,141 +8.93% 24
Kazakhstan Kazakhstan -574,104,682 -44.6% 101
Cambodia Cambodia 3,161,873,166 -0.37% 32
Kiribati Kiribati 102,945,971 +23.6% 86
St. Kitts & Nevis St. Kitts & Nevis -18,300,000 +18.1% 95
Kuwait Kuwait -14,094,596,114 +9.05% 116
Laos Laos 390,440,758 +24.1% 73
Liberia Liberia 413,000,000 -6.14% 70
St. Lucia St. Lucia 34,000,000 +0.592% 91
Sri Lanka Sri Lanka 6,430,211,705 +10.5% 20
Morocco Morocco 13,572,504,302 +3.3% 10
Moldova Moldova 1,626,198,586 -10.4% 42
Madagascar Madagascar 1,097,895,254 +21.1% 48
Maldives Maldives -589,112,227 +8.94% 102
Mexico Mexico 67,136,498,206 +6.76% 2
Marshall Islands Marshall Islands 91,650,058 +17.2% 87
North Macedonia North Macedonia 2,691,119,986 -7.74% 34
Mali Mali 940,949,757 -24.8% 52
Myanmar (Burma) Myanmar (Burma) 1,408,000,000 -14.6% 44
Montenegro Montenegro 467,100,405 -1.46% 68
Mongolia Mongolia 447,304,250 +12.2% 69
Mozambique Mozambique 1,087,954,427 -16.5% 49
Mauritania Mauritania 335,306,641 +12.3% 76
Mauritius Mauritius -813,384,991 +42.7% 104
Malawi Malawi 582,383,963 +4.76% 65
Malaysia Malaysia -1,942,692,410 -25.1% 106
Namibia Namibia 1,697,218,853 +20.7% 41
Nigeria Nigeria 24,040,999,994 +8.66% 4
Nicaragua Nicaragua 5,109,099,999 +12.5% 27
Nepal Nepal 11,810,759,775 +12.8% 12
Pakistan Pakistan 32,201,000,000 +13.6% 3
Peru Peru 7,193,176,617 +5.57% 19
Papua New Guinea Papua New Guinea 290,337,966 +201% 77
Poland Poland -3,955,252,020 +79.6% 111
Portugal Portugal 5,439,963,057 +5.97% 26
Paraguay Paraguay 809,611,005 +19.7% 55
Qatar Qatar -10,189,010,989 -27.3% 114
Romania Romania 1,491,817,458 -38% 43
Russia Russia -3,053,836,997 -67.1% 110
Rwanda Rwanda 802,346,747 -9.7% 56
Saudi Arabia Saudi Arabia -55,737,200,000 +8.44% 118
Singapore Singapore -7,571,583,698 +11.2% 113
Solomon Islands Solomon Islands 146,258,567 +10.5% 84
Sierra Leone Sierra Leone 408,400,008 -13.8% 72
El Salvador El Salvador 8,391,950,000 +2.64% 18
Somalia Somalia 6,381,000,000 +13.1% 21
Serbia Serbia 5,711,178,730 -6.36% 25
São Tomé & Príncipe São Tomé & Príncipe 82,700,000 +145% 88
Suriname Suriname 153,166,411 +10.3% 82
Slovakia Slovakia 633,609,291 +10% 61
Sweden Sweden -10,595,462,921 +15.9% 115
Eswatini Eswatini 729,833,451 +22.5% 57
Seychelles Seychelles -21,172,663 +9.12% 96
Togo Togo 635,858,241 -7.85% 60
Thailand Thailand 9,239,152,788 -6.92% 16
Tajikistan Tajikistan 1,720,519,780 -23.8% 40
Trinidad & Tobago Trinidad & Tobago 29,700,000 -75.2% 92
Tunisia Tunisia 3,420,249,733 +10.8% 30
Turkey Turkey 72,000,000 -87.1% 89
Tanzania Tanzania 606,718,003 -6.1% 63
Uganda Uganda 1,819,869,042 -11.8% 39
Ukraine Ukraine 21,832,000,000 -6.08% 7
Uruguay Uruguay 202,751,321 +14.5% 79
Uzbekistan Uzbekistan 10,578,217,988 +20.1% 13
St. Vincent & Grenadines St. Vincent & Grenadines 64,807,407 +6.1% 90
Vietnam Vietnam 13,029,000,000 -0.199% 11
Samoa Samoa 282,071,594 +1.8% 78
Kosovo Kosovo 2,166,276,490 -1.84% 36
South Africa South Africa -2,513,495,594 +16.2% 107
Zimbabwe Zimbabwe 4,436,620,651 +49.7% 28

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