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

Source: worldbank.org, 03.09.2025

Year: 2022

Flag Country Value Value change, % Rank
Angola Angola 8,752 -99.2% 65
Albania Albania 4,000 -27.3% 78
Argentina Argentina 3,314 -99.5% 81
Armenia Armenia 44,813 +90.1% 33
Azerbaijan Azerbaijan 1,500 -98.5% 83
Benin Benin 17,622 -96.7% 54
Burkina Faso Burkina Faso 31,402 -95.4% 39
Bangladesh Bangladesh 3,500 -97.9% 80
Belarus Belarus 42,761 -60.5% 34
Bolivia Bolivia 4,016 -33.1% 77
Brazil Brazil 75,672 -86.5% 22
Botswana Botswana 101,095 -83.4% 17
Central African Republic Central African Republic 11,800 -98.9% 60
China China 161,429 -84.8% 10
Côte d’Ivoire Côte d’Ivoire 80,557 -90.5% 21
Cameroon Cameroon 31,433 -96.9% 38
Congo - Kinshasa Congo - Kinshasa 6,575 -99.6% 69
Congo - Brazzaville Congo - Brazzaville 4,596 -99% 75
Djibouti Djibouti 1,610 -99.2% 82
Dominican Republic Dominican Republic 71,487 -81.8% 23
Algeria Algeria 14,476 -93% 57
Ecuador Ecuador 4,900 -38.9% 74
Egypt Egypt 82,465 -26.6% 18
Eritrea Eritrea 3,989 -94.6% 79
Ethiopia Ethiopia 20,153 -98.2% 51
Gabon Gabon 29,740 -94.5% 41
Georgia Georgia 20,040 -72.4% 52
Ghana Ghana 324,932 -59.7% 3
Guinea Guinea 6,224 -98.7% 71
Gambia Gambia 7,175 -93.5% 67
Equatorial Guinea Equatorial Guinea 7,871 -97.3% 66
Guatemala Guatemala 63,863 -90% 25
Guyana Guyana 1,200 -99.7% 84
Honduras Honduras 11,770 -49.8% 61
Haiti Haiti 104,664 -87% 14
Indonesia Indonesia 751,025 +3.07% 1
India India 59,868 -93.3% 27
Iran Iran 34,939 -92% 36
Iraq Iraq 19,500 -78.3% 53
Jamaica Jamaica 25,575 -98.3% 46
Kazakhstan Kazakhstan 80,900 -87.9% 19
Kenya Kenya 56,987 -96.2% 28
Kyrgyzstan Kyrgyzstan 34,613 -63.4% 37
Cambodia Cambodia 337,080 -42.2% 2
Laos Laos 10,045 -90.1% 63
Libya Libya 27,000 -46% 44
Lesotho Lesotho 60,248 -91.7% 26
Morocco Morocco 30,048 -94.3% 40
Moldova Moldova 17,386 -79% 55
Madagascar Madagascar 20,887 -95% 49
Mexico Mexico 24,883 +451% 47
Mali Mali 48,550 -94.5% 31
Myanmar (Burma) Myanmar (Burma) 149,305 -74.8% 11
Mongolia Mongolia 20,759 +3,668% 50
Mozambique Mozambique 27,259 -97.2% 43
Malawi Malawi 42,165 -94.8% 35
Namibia Namibia 188,583 -74.5% 9
Niger Niger 15,039 -97.4% 56
Nigeria Nigeria 25,586 -99% 45
Nepal Nepal 103,745 -44.5% 16
Pakistan Pakistan 5,130 -99.3% 73
Peru Peru 54,961 -90.6% 29
Philippines Philippines 193,091 -36.3% 7
Paraguay Paraguay 6,000 -60% 72
Rwanda Rwanda 53,046 -90.7% 30
Sudan Sudan 46,850 -81.7% 32
Senegal Senegal 12,886 -94.5% 58
Sierra Leone Sierra Leone 6,586 -98.6% 68
El Salvador El Salvador 6,504 -95.5% 70
Serbia Serbia 4,000 -90% 78
South Sudan South Sudan 29,073 -96.7% 42
Eswatini Eswatini 4,022 -99.4% 76
Chad Chad 23,851 -96.3% 48
Togo Togo 11,069 -98% 62
Thailand Thailand 104,267 -75% 15
Tajikistan Tajikistan 80,639 +30.3% 20
Tunisia Tunisia 857 -98.8% 85
Tanzania Tanzania 68,717 -96.1% 24
Uganda Uganda 276,598 -74.9% 4
Ukraine Ukraine 268,999 -68.7% 5
Uzbekistan Uzbekistan 12,716 -77.8% 59
Venezuela Venezuela 108,808 -58% 12
Vietnam Vietnam 9,914 -98.2% 64
South Africa South Africa 190,507 -91.5% 8
Zambia Zambia 105,886 -91.4% 13
Zimbabwe Zimbabwe 241,121 -81.5% 6

                    
# 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.UNAI.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.UNAI.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))