Net ODA received (% of central government expense)

Source: worldbank.org, 01.09.2025

Year: 2021

Flag Country Value Value change, % Rank
Albania Albania 14.4 +74.4% 38
Argentina Argentina 0.139 +36.6% 75
Armenia Armenia 4.67 +24.1% 50
Azerbaijan Azerbaijan 0.0656 -92.3% 77
Burundi Burundi 145 +41% 2
Burkina Faso Burkina Faso 41.2 -24% 16
Bangladesh Bangladesh 14.7 -16.7% 36
Bosnia & Herzegovina Bosnia & Herzegovina 6.84 +21% 47
Belarus Belarus 0.719 -59.5% 67
Brazil Brazil 0.226 +90.3% 72
Botswana Botswana 1.81 +16.2% 61
Central African Republic Central African Republic 225 -12.3% 1
Côte d’Ivoire Côte d’Ivoire 13.2 -14.5% 39
Cameroon Cameroon 20.4 -28.4% 31
Congo - Kinshasa Congo - Kinshasa 70.7 -7.58% 4
Congo - Brazzaville Congo - Brazzaville 8.53 -19.3% 42
Colombia Colombia 1.69 -10.8% 62
Costa Rica Costa Rica 0.396 -62.2% 71
Dominican Republic Dominican Republic 2.72 +22.4% 55
Ecuador Ecuador 0.879 -16.6% 65
Ethiopia Ethiopia 43.5 -25.8% 15
Fiji Fiji 40.4 +187% 18
Gabon Gabon 3.61 +70.8% 53
Georgia Georgia 15 -33.1% 35
Ghana Ghana 7.51 -47.8% 44
Guinea-Bissau Guinea-Bissau 62.3 +8.63% 6
Equatorial Guinea Equatorial Guinea 1.01 +101% 63
Guatemala Guatemala 4.47 +10% 51
Jordan Jordan 26.1 +3.21% 25
Kazakhstan Kazakhstan 0.171 -33.6% 74
Kenya Kenya 12.3 -38.1% 40
Kyrgyzstan Kyrgyzstan 20.9 -5.97% 30
Cambodia Cambodia 29.5 -3.14% 22
Kiribati Kiribati 30.4 -12.2% 21
Laos Laos 28.4 +16.6% 24
Lebanon Lebanon 96.1 +220% 3
Sri Lanka Sri Lanka 0.996 -26.6% 64
Lesotho Lesotho 19.5 +1.44% 33
Morocco Morocco 2.65 -52.1% 56
Moldova Moldova 14.5 +4.62% 37
Madagascar Madagascar 69.6 -17.5% 5
Maldives Maldives 7.26 -69.4% 45
Mexico Mexico 0.205 -37.2% 73
North Macedonia North Macedonia 7.25 +10.7% 46
Mongolia Mongolia 5.82 -63.4% 49
Mozambique Mozambique 60.6 -22.7% 7
Mauritius Mauritius 7.75 -16.4% 43
Malawi Malawi 55.4 -26.1% 11
Malaysia Malaysia 0.0223 -368% 78
Namibia Namibia 3.92 -7.35% 52
Nicaragua Nicaragua 30.9 +40.1% 20
Nepal Nepal 22.3 -14.7% 29
Panama Panama 0.791 -39.9% 66
Peru Peru 0.587 -34.9% 69
Philippines Philippines 2.17 +5.25% 59
Papua New Guinea Papua New Guinea 22.9 +8.05% 28
Paraguay Paraguay 2.62 -43.8% 57
Palestinian Territories Palestinian Territories 45.6 +1.8% 14
Rwanda Rwanda 59.2 -20.2% 9
Senegal Senegal 25.8 -17.9% 26
Solomon Islands Solomon Islands 55.9 +27.9% 10
El Salvador El Salvador 2.49 -38.6% 58
Serbia Serbia 2.14 +4.06% 60
Eswatini Eswatini 10.6 +8.08% 41
Togo Togo 31.2 -40.8% 19
Thailand Thailand 0.104 -40% 76
Tajikistan Tajikistan 49.9 -37.7% 13
Timor-Leste Timor-Leste 17.1 -22.8% 34
Tonga Tonga 60.5 -40.8% 8
Turkey Turkey 0.418 +89% 70
Tanzania Tanzania 24.5 +1.59% 27
Uganda Uganda 40.6 -32.4% 17
Ukraine Ukraine 3.33 -16.9% 54
Uzbekistan Uzbekistan 6.55 -43.4% 48
Vanuatu Vanuatu 51.3 +3.02% 12
Samoa Samoa 28.5 -55.7% 23
South Africa South Africa 0.717 -23.8% 68
Zambia Zambia 19.6 -11.3% 32

                    
# 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.ODA.ODAT.XP.ZS'

# 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.ODA.ODAT.XP.ZS'

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