Net official flows from UN agencies, UNFPA (current US$)

Source: worldbank.org, 03.09.2025

Year: 2022

Flag Country Value Value change, % Rank
Afghanistan Afghanistan 6,998,700 +0.612% 4
Angola Angola 3,412,810 +8.06% 35
Albania Albania 772,170 -14.8% 108
Argentina Argentina 953,670 +141% 98
Armenia Armenia 840,320 -3.14% 104
Azerbaijan Azerbaijan 1,007,850 +10.1% 93
Burundi Burundi 3,196,540 +17.3% 41
Benin Benin 2,941,130 +20.9% 45
Burkina Faso Burkina Faso 4,204,520 +22.7% 23
Bangladesh Bangladesh 6,728,200 +22.8% 5
Bosnia & Herzegovina Bosnia & Herzegovina 1,322,250 +14.3% 82
Belarus Belarus 702,420 +26.2% 112
Bolivia Bolivia 1,968,810 +5.12% 60
Brazil Brazil 2,904,600 +12.8% 47
Bhutan Bhutan 991,110 +24.5% 95
Botswana Botswana 927,540 +2.22% 99
Central African Republic Central African Republic 3,785,110 +11.4% 26
China China 3,052,170 +7.74% 43
Côte d’Ivoire Côte d’Ivoire 4,621,210 +1.91% 19
Cameroon Cameroon 4,336,210 +17.5% 21
Congo - Kinshasa Congo - Kinshasa 9,901,630 +12.4% 1
Congo - Brazzaville Congo - Brazzaville 2,764,970 +17.6% 49
Colombia Colombia 2,162,590 -11.6% 55
Comoros Comoros 1,003,530 -13.7% 94
Cape Verde Cape Verde 1,334,200 +39.9% 80
Costa Rica Costa Rica 768,870 +20.4% 109
Cuba Cuba 811,700 +17.2% 107
Djibouti Djibouti 1,283,950 +49.6% 84
Dominican Republic Dominican Republic 1,323,870 +18.7% 81
Algeria Algeria 967,700 +20.2% 97
Ecuador Ecuador 1,544,340 -12.8% 72
Egypt Egypt 1,751,260 -337% 67
Eritrea Eritrea 1,167,340 -25.7% 89
Ethiopia Ethiopia 6,183,090 -0.985% 11
Gabon Gabon 1,854,750 +82.8% 64
Georgia Georgia 815,990 -1.26% 105
Ghana Ghana 3,778,300 -4.26% 27
Guinea Guinea 3,417,110 -2.6% 34
Gambia Gambia 1,494,320 +24% 75
Guinea-Bissau Guinea-Bissau 1,512,330 -11.1% 74
Equatorial Guinea Equatorial Guinea 1,477,960 +45.8% 76
Guatemala Guatemala 2,543,960 +11.8% 52
Honduras Honduras 1,742,790 +10.9% 68
Haiti Haiti 3,558,780 +4.41% 32
Indonesia Indonesia 4,168,590 +15.3% 24
India India 6,193,750 -5.95% 10
Iran Iran 1,934,640 -10.8% 61
Iraq Iraq 3,321,920 -9.16% 36
Jordan Jordan 1,532,230 +50.6% 73
Kazakhstan Kazakhstan 1,171,980 +8.95% 88
Kenya Kenya 4,836,050 +11.2% 17
Kyrgyzstan Kyrgyzstan 1,162,120 -9.26% 91
Cambodia Cambodia 2,952,320 +23% 44
Laos Laos 2,112,080 +7.3% 56
Lebanon Lebanon 1,337,240 -16.9% 79
Liberia Liberia 2,795,870 +37.9% 48
Libya Libya 2,053,710 -3.15% 58
Sri Lanka Sri Lanka 2,923,360 +149% 46
Lesotho Lesotho 1,195,090 -16.9% 87
Morocco Morocco 1,809,390 -0.849% 66
Moldova Moldova 1,597,850 +22.7% 70
Madagascar Madagascar 5,329,780 +15.2% 14
Maldives Maldives 845,110 +78.4% 103
Mexico Mexico 2,177,640 +17% 54
North Macedonia North Macedonia 671,590 +64.7% 113
Mali Mali 4,947,050 +28.6% 16
Myanmar (Burma) Myanmar (Burma) 3,952,300 +18.3% 25
Mongolia Mongolia 1,614,700 +20.3% 69
Mozambique Mozambique 5,637,450 +14.2% 13
Mauritania Mauritania 2,105,310 +9.11% 57
Mauritius Mauritius 252,880 +68.7% 114
Malawi Malawi 3,673,100 +7.31% 31
Malaysia Malaysia 898,500 +55.7% 100
Namibia Namibia 1,378,970 -5% 78
Niger Niger 4,806,450 +29.4% 18
Nigeria Nigeria 9,880,390 +47.1% 2
Nicaragua Nicaragua 1,594,300 +11.4% 71
Nepal Nepal 3,717,870 -9.41% 29
Pakistan Pakistan 5,711,380 -5.37% 12
Panama Panama 854,710 +18% 102
Peru Peru 1,890,140 +17.9% 63
Philippines Philippines 4,506,750 +0.665% 20
Papua New Guinea Papua New Guinea 3,308,460 +36.6% 37
North Korea North Korea 856,510 -27% 101
Paraguay Paraguay 1,203,380 +7.63% 86
Palestinian Territories Palestinian Territories 2,742,620 -2.28% 50
Rwanda Rwanda 3,704,010 +116% 30
Sudan Sudan 5,065,050 -4.73% 15
Senegal Senegal 3,252,790 +11.5% 39
Sierra Leone Sierra Leone 3,290,930 +47.2% 38
El Salvador El Salvador 1,304,050 -12.5% 83
Somalia Somalia 6,554,010 +105% 8
Serbia Serbia 812,060 +13.7% 106
South Sudan South Sudan 7,579,290 +15.9% 3
São Tomé & Príncipe São Tomé & Príncipe 703,560 -9.09% 111
Eswatini Eswatini 1,019,260 -15.7% 92
Syria Syria 3,243,770 -20.1% 40
Chad Chad 4,213,300 +9.16% 22
Togo Togo 2,563,540 +3.35% 51
Thailand Thailand 1,165,320 +27.1% 90
Tajikistan Tajikistan 1,237,770 +15.3% 85
Turkmenistan Turkmenistan 984,870 +32.9% 96
Timor-Leste Timor-Leste 1,996,240 +13.1% 59
Tunisia Tunisia 748,360 +14.4% 110
Turkey Turkey 2,271,360 +0.397% 53
Tanzania Tanzania 6,496,320 +28.9% 9
Uganda Uganda 6,676,850 +46.2% 6
Ukraine Ukraine 1,815,470 +0.703% 65
Venezuela Venezuela 1,446,230 -17.3% 77
Vietnam Vietnam 3,521,490 -6.09% 33
Yemen Yemen 6,570,800 +10.5% 7
South Africa South Africa 1,900,090 -0.571% 62
Zambia Zambia 3,129,870 +19.9% 42
Zimbabwe Zimbabwe 3,759,510 +18.3% 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 = 'DT.NFL.UNFP.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 <- 'DT.NFL.UNFP.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))