Total reserves in months of imports

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 5.51 +8.34% 37
Albania Albania 6.04 -10.2% 28
Argentina Argentina 3.59 +45.1% 61
Armenia Armenia 2.13 -21.2% 77
Antigua & Barbuda Antigua & Barbuda 3.04 -4.16% 68
Australia Australia 1.37 -4.83% 90
Austria Austria 1.28 +14.8% 94
Azerbaijan Azerbaijan 4.66 -14.7% 47
Belgium Belgium 0.79 +3.95% 97
Bangladesh Bangladesh 3.21 -5.25% 64
Bulgaria Bulgaria 7.59 -5.93% 14
Bahrain Bahrain 1.42 -7.9% 87
Bosnia & Herzegovina Bosnia & Herzegovina 6.42 -3.44% 25
Belarus Belarus 1.98 +4.33% 81
Belize Belize 3.19 -4.41% 65
Brazil Brazil 8.11 -14.1% 11
Brunei Brunei 5.51 +0.734% 38
Bhutan Bhutan 6.55 +62.8% 23
Canada Canada 1.57 -0.411% 86
Switzerland Switzerland 13.2 +1.85% 3
Chile Chile 4.15 -5.19% 56
China China 11.2 -3.53% 5
Colombia Colombia 7.3 +1.91% 19
Cape Verde Cape Verde 5.98 -10.9% 29
Costa Rica Costa Rica 4.26 -1.89% 55
Cyprus Cyprus 0.365 +13.4% 102
Czechia Czechia 7.03 -0.874% 20
Germany Germany 2.18 +16.8% 76
Djibouti Djibouti 0.85 -23% 96
Dominica Dominica 4.73 -8.43% 46
Denmark Denmark 4.51 -5.1% 50
Dominican Republic Dominican Republic 3.65 -19.2% 59
Ecuador Ecuador 2.2 +59.4% 75
Spain Spain 1.83 +0.0346% 85
Estonia Estonia 0.679 -21.4% 100
Finland Finland 1.4 +8.08% 88
France France 2.38 +15.4% 72
United Kingdom United Kingdom 1.22 -3.63% 95
Georgia Georgia 2.33 -14.2% 74
Greece Greece 1.31 +8.18% 93
Grenada Grenada 4.39 -1.46% 53
Guatemala Guatemala 7.39 +6.71% 17
Honduras Honduras 4.46 +3.54% 51
Croatia Croatia 0.706 -2.29% 99
Hungary Hungary 2.9 +5.89% 69
Indonesia Indonesia 5.74 +0.268% 32
India India 7.52 -5.67% 15
Iceland Iceland 4.92 +0.325% 43
Israel Israel 15.7 +3.83% 2
Italy Italy 4 +18.9% 57
Japan Japan 13 -3.48% 4
Kazakhstan Kazakhstan 5.49 +31.4% 39
Cambodia Cambodia 7.65 -1.53% 13
St. Kitts & Nevis St. Kitts & Nevis 5.05 +6.61% 42
South Korea South Korea 6.25 -0.868% 26
Kuwait Kuwait 8.95 -2.35% 10
St. Lucia St. Lucia 2.78 -16% 71
Lesotho Lesotho 5.52 +17.3% 36
Lithuania Lithuania 1.39 +18.8% 89
Luxembourg Luxembourg 0.0596 -10.1% 104
Latvia Latvia 1.86 +5.64% 84
Moldova Moldova 5.77 -5.87% 30
Maldives Maldives 1.32 +7.68% 92
Mexico Mexico 3.6 +3.66% 60
North Macedonia North Macedonia 4.58 +4.66% 48
Malta Malta 0.352 +12.8% 103
Montenegro Montenegro 3.47 +1.98% 62
Mozambique Mozambique 3.44 +5.21% 63
Malaysia Malaysia 4.45 -6.85% 52
Namibia Namibia 3.91 +3.81% 58
Nigeria Nigeria 6.79 +38.5% 21
Nicaragua Nicaragua 5.72 +2.01% 34
Netherlands Netherlands 0.727 +13.9% 98
Norway Norway 4.56 -2.37% 49
New Zealand New Zealand 3.12 +40.7% 67
Pakistan Pakistan 2.86 +14.2% 70
Panama Panama 2.07 +12.1% 79
Peru Peru 10.5 +2.89% 7
Philippines Philippines 7.33 -3.79% 18
Poland Poland 5.38 +10.7% 40
Portugal Portugal 3.15 +17.8% 66
Palestinian Territories Palestinian Territories 1.91 +41.3% 83
Qatar Qatar 6.72 +3.75% 22
Romania Romania 4.91 -3.53% 44
Saudi Arabia Saudi Arabia 15.9 -8.69% 1
Singapore Singapore 4.29 -2.08% 54
El Salvador El Salvador 2.11 +12.1% 78
Suriname Suriname 6.51 +3.57% 24
Slovakia Slovakia 1.35 +27% 91
Slovenia Slovenia 0.578 +16.5% 101
Sweden Sweden 1.98 -0.0549% 80
Thailand Thailand 7.44 -1.7% 16
Timor-Leste Timor-Leste 5.73 -9.17% 33
Tonga Tonga 11 -8.11% 6
Trinidad & Tobago Trinidad & Tobago 6.07 -19.8% 27
Turkey Turkey 4.73 +13.7% 45
Ukraine Ukraine 5.21 +3.28% 41
Uruguay Uruguay 7.76 +7.46% 12
United States United States 1.97 +9.49% 82
Uzbekistan Uzbekistan 10.3 +16.4% 8
St. Vincent & Grenadines St. Vincent & Grenadines 5.76 +2.3% 31
Vietnam Vietnam 2.37 -21.3% 73
Samoa Samoa 9.8 +10.9% 9
South Africa South Africa 5.68 +6.41% 35

                    
# 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 = 'FI.RES.TOTL.MO'

# 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 <- 'FI.RES.TOTL.MO'

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