Net financial flows, IMF nonconcessional (NFL, current US$)

Source: worldbank.org, 03.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Afghanistan Afghanistan -4,202,255 -16.3% 42
Angola Angola -178,873,301 63
Argentina Argentina -5,073,959,569 -177% 70
Armenia Armenia -93,668,921 -258% 57
Benin Benin 135,539,385 -29.9% 20
Burkina Faso Burkina Faso 93,458,141 -500% 23
Bangladesh Bangladesh 921,914,618 -680% 2
Bosnia & Herzegovina Bosnia & Herzegovina -116,646,582 +450% 60
Central African Republic Central African Republic 17,318,625 -272% 29
Côte d’Ivoire Côte d’Ivoire 668,479,980 -503% 3
Cameroon Cameroon 165,688,894 -10.3% 17
Congo - Kinshasa Congo - Kinshasa 406,351,345 -0.314% 7
Congo - Brazzaville Congo - Brazzaville 172,892,759 -0.314% 16
Colombia Colombia 0 35
Comoros Comoros 2,944,246 -220% 33
Cape Verde Cape Verde 21,024,613 +39.5% 27
Costa Rica Costa Rica 213,521,223 -61.3% 13
Djibouti Djibouti 0 -100% 35
Dominican Republic Dominican Republic -159,218,756 62
Ecuador Ecuador -228,950,835 -114% 64
Egypt Egypt -2,595,708,627 +238% 69
Ethiopia Ethiopia 0 35
Gabon Gabon -117,556,404 -195% 61
Georgia Georgia -30,016,104 +79.4% 48
Ghana Ghana 478,139,194 -496% 5
Guinea Guinea -45,821,917 -208% 50
Gambia Gambia 1,276,685 -95.9% 34
Guinea-Bissau Guinea-Bissau 12,613,434 -568% 31
Grenada Grenada -3,746,010 +7.33% 41
Honduras Honduras 45,419,034 24
Haiti Haiti 96,866,565 -873% 21
Jamaica Jamaica 18,675,353 -115% 28
Jordan Jordan -101,431,753 -120% 59
Kenya Kenya 380,342,725 -38.9% 8
Kyrgyzstan Kyrgyzstan -70,936,725 +228% 55
St. Lucia St. Lucia 0 35
Sri Lanka Sri Lanka 505,497,872 -462% 4
Lesotho Lesotho -6,148,632 -5.23% 43
Morocco Morocco 0 35
Moldova Moldova 161,326,554 +14.2% 18
Madagascar Madagascar 15,599,036 -79.9% 30
Maldives Maldives 0 35
North Macedonia North Macedonia -46,791,771 -142% 51
Mali Mali -35,832,558 +76.2% 49
Myanmar (Burma) Myanmar (Burma) -57,454,825 52
Montenegro Montenegro -20,177,492 47
Mongolia Mongolia -59,075,695 +146% 53
Mauritania Mauritania 34,856,034 -493% 25
Malawi Malawi 5,344,201 -91.6% 32
Nigeria Nigeria -818,605,858 68
Nicaragua Nicaragua 0 35
Nepal Nepal 95,077,677 -5.19% 22
Pakistan Pakistan -82,767,072 -107% 56
Papua New Guinea Papua New Guinea 175,587,538 15
Rwanda Rwanda 194,280,233 -704% 14
Sudan Sudan 0 35
Senegal Senegal 424,485,074 +63.4% 6
Solomon Islands Solomon Islands -237,461 +19.1% 36
El Salvador El Salvador -95,784,723 58
Somalia Somalia -275,387,749 -1,080% 65
Serbia Serbia 218,383,832 -79.2% 12
São Tomé & Príncipe São Tomé & Príncipe -993,867 -122% 39
Suriname Suriname 157,684,600 +199% 19
Eswatini Eswatini -13,089,689 45
Togo Togo -16,789,008 +398% 46
Tajikistan Tajikistan 0 -100% 35
Tonga Tonga 0 -100% 35
Tunisia Tunisia -420,474,923 +247% 66
Tanzania Tanzania 302,482,285 +95.9% 11
Uganda Uganda 361,193,785 +199% 10
Ukraine Ukraine 1,914,253,685 +197% 1
Uzbekistan Uzbekistan -61,216,844 54
St. Vincent & Grenadines St. Vincent & Grenadines -553,630 -0.314% 37
Vanuatu Vanuatu -2,267,883 -0.314% 40
Samoa Samoa -773,749 -50.2% 38
Kosovo Kosovo 27,549,447 -308% 26
Yemen Yemen -13,006,978 -11.3% 44
South Africa South Africa -508,806,314 67
Zambia Zambia 373,213,567 +99.4% 9

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