Net financial flows, IBRD (NFL, current US$)

Source: worldbank.org, 03.09.2025

Year: 2004

Flag Country Value Value change, % Rank
Argentina Argentina -61,027,000 -93.9% 67
Armenia Armenia -586,000 +14.2% 28
Bangladesh Bangladesh -7,278,000 +15.5% 43
Bosnia & Herzegovina Bosnia & Herzegovina -24,381,000 +1.18% 57
Belarus Belarus -13,512,000 -5.83% 51
Belize Belize -1,737,000 -37.1% 33
Bolivia Bolivia 150,000 -162% 23
Brazil Brazil -116,344,000 -66% 71
Barbados Barbados -6,000 -100% 26
Botswana Botswana -1,679,000 -44.8% 31
Chile Chile 18,803,000 -114% 12
China China 306,268,000 -137% 3
Côte d’Ivoire Côte d’Ivoire -38,363,000 -53.3% 61
Cameroon Cameroon -29,661,000 +3,252% 59
Congo - Brazzaville Congo - Brazzaville -3,153,000 -50.9% 38
Colombia Colombia 199,990,000 -74.2% 4
Costa Rica Costa Rica -8,734,000 -24.5% 46
Czechia Czechia -18,862,000 -86% 55
Dominica Dominica 4,000 -99.1% 24
Dominican Republic Dominican Republic 29,312,000 -2,493% 11
Algeria Algeria -149,239,000 -1.75% 73
Ecuador Ecuador -52,933,000 -189% 65
Egypt Egypt -51,783,000 +7.93% 64
Estonia Estonia -4,137,000 -316% 40
Fiji Fiji -2,251,000 +6.63% 35
Gabon Gabon -11,684,000 +262% 49
Ghana Ghana -1,607,000 -16.6% 30
Equatorial Guinea Equatorial Guinea 0 25
Greece Greece 0 25
Grenada Grenada 1,456,000 -33.5% 18
Guatemala Guatemala 50,017,000 +84.6% 7
Guyana Guyana -913,000 -60.8% 29
Honduras Honduras -15,056,000 -27% 52
Croatia Croatia 35,945,602 -68.1% 9
Hungary Hungary -39,497,000 -85.9% 62
Indonesia Indonesia -825,623,000 -13.1% 79
India India 748,821,000 -126% 2
Iran Iran -34,301,000 -30.4% 60
Jamaica Jamaica -40,715,000 +29.6% 63
Jordan Jordan -56,730,000 +89.1% 66
Kazakhstan Kazakhstan -27,365,000 +562% 58
Kenya Kenya -4,764,000 -38.2% 42
St. Kitts & Nevis St. Kitts & Nevis 1,309,000 -59.3% 19
South Korea South Korea -1,806,789,000 -23.3% 82
Lebanon Lebanon 14,174,000 -37.4% 13
St. Lucia St. Lucia 160,000 -95.6% 22
Sri Lanka Sri Lanka -1,968,000 +9.03% 34
Lesotho Lesotho -2,368,000 -87.2% 36
Lithuania Lithuania -92,766,000 +364% 70
Latvia Latvia -8,001,000 -92.5% 44
Morocco Morocco -292,593,000 +79.6% 76
Moldova Moldova -10,398,000 +14.6% 48
Mexico Mexico -1,150,418,000 +1,342% 80
North Macedonia North Macedonia 32,185,000 +77.1% 10
Malta Malta 0 25
Mauritius Mauritius -9,034,000 -28.8% 47
Malawi Malawi -485,000 -72.2% 27
Malaysia Malaysia -69,787,000 +555% 68
Nigeria Nigeria -216,424,000 +6.79% 74
Oman Oman 0 25
Pakistan Pakistan -303,118,000 +25.8% 77
Peru Peru 45,445,000 -74.8% 8
Philippines Philippines -226,433,000 +65.4% 75
Papua New Guinea Papua New Guinea -12,957,000 -13.2% 50
Poland Poland -676,540,000 +223% 78
Paraguay Paraguay -16,663,000 -173% 54
El Salvador El Salvador -24,280,000 -2,426% 56
Serbia Serbia 0 25
Slovakia Slovakia 74,425,000 +31.9% 5
Slovenia Slovenia -8,396,872 -1.94% 45
Eswatini Eswatini 8,815,000 +52.2% 14
Seychelles Seychelles 0 -100% 25
Syria Syria -4,450,000 -41% 41
Chad Chad 5,919,000 -72.6% 16
Thailand Thailand -1,614,990,000 +545% 81
Turkmenistan Turkmenistan 1,304,000 -183% 20
Trinidad & Tobago Trinidad & Tobago -15,240,000 +705% 53
Tunisia Tunisia -88,681,000 -294% 69
Turkey Turkey 919,467,000 -518% 1
Tanzania Tanzania -2,865,000 +8.52% 37
Ukraine Ukraine -132,855,000 +280% 72
Uruguay Uruguay 63,575,000 +230% 6
Uzbekistan Uzbekistan 4,510,000 +62.5% 17
St. Vincent & Grenadines St. Vincent & Grenadines 360,000 +253% 21
South Africa South Africa 6,961,000 +122% 15
Zambia Zambia -3,283,000 -54.4% 39
Zimbabwe Zimbabwe -1,694,000 +2,129% 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.NFL.MIBR.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.MIBR.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))