Gross domestic savings (current US$)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 30,929,617,718 -5.21% 47
Albania Albania 4,783,451,375 +14.5% 93
Argentina Argentina 106,811,815,779 -6.4% 33
Armenia Armenia 5,860,235,785 +18.8% 87
Australia Australia 464,739,248,500 -5.13% 10
Austria Austria 132,060,199,742 -5.45% 28
Azerbaijan Azerbaijan 22,441,647,059 -3.78% 57
Belgium Belgium 159,574,919,556 -0.036% 24
Benin Benin 6,896,565,400 +17.3% 84
Burkina Faso Burkina Faso 4,799,426,902 +52.9% 92
Bangladesh Bangladesh 107,835,911,368 -4.3% 31
Bulgaria Bulgaria 25,449,185,825 +4.2% 53
Bahamas Bahamas 3,608,300,000 +0.58% 97
Bosnia & Herzegovina Bosnia & Herzegovina 3,228,989,402 -6.71% 98
Belarus Belarus 18,380,674,957 -10.1% 66
Bermuda Bermuda 3,896,200,000 +5.2% 96
Brazil Brazil 379,389,162,608 -3.98% 14
Brunei Brunei 7,494,089,237 +0.22% 83
Botswana Botswana 4,382,924,796 -18.8% 94
Central African Republic Central African Republic -118,970,031 -18.3% 122
Canada Canada 516,444,266,538 -0.842% 8
Switzerland Switzerland 348,499,957,502 +4.37% 15
Chile Chile 88,598,951,087 +8.85% 34
Côte d’Ivoire Côte d’Ivoire 21,639,471,701 +20.3% 59
Cameroon Cameroon 7,682,392,922 +0.399% 82
Congo - Kinshasa Congo - Kinshasa 20,643,367,736 +5.33% 61
Congo - Brazzaville Congo - Brazzaville 6,164,717,196 -5.97% 86
Colombia Colombia 50,829,634,622 +18.5% 42
Comoros Comoros -198,078,686 +4.59% 123
Cape Verde Cape Verde 126,715,360 +253% 117
Costa Rica Costa Rica 20,406,515,063 +14.4% 62
Cyprus Cyprus 8,184,324,974 +11.4% 79
Czechia Czechia 112,495,746,621 -0.72% 30
Germany Germany 1,160,498,031,941 -0.139% 2
Djibouti Djibouti 335,972,716 -30.1% 115
Denmark Denmark 139,340,670,014 +10.5% 26
Dominican Republic Dominican Republic 25,789,047,307 +3.84% 52
Ecuador Ecuador 27,224,852,700 +8.12% 51
Egypt Egypt 23,921,801,408 -57.6% 55
Spain Spain 426,469,810,873 +5.59% 11
Estonia Estonia 10,969,295,023 +2.74% 74
Finland Finland 68,103,379,094 +0.968% 38
France France 670,287,484,692 +3.83% 5
Gabon Gabon 11,306,837,977 +2.74% 73
United Kingdom United Kingdom 615,511,279,702 +12.3% 6
Georgia Georgia 5,137,210,010 +1.89% 90
Ghana Ghana 9,199,945,807 +26.2% 75
Guinea Guinea 4,855,385,466 +36.6% 91
Gambia Gambia 209,366,310 +30.2% 116
Guinea-Bissau Guinea-Bissau 110,677,366 +12.9% 118
Equatorial Guinea Equatorial Guinea 2,392,671,833 -8.18% 106
Greece Greece 32,967,148,647 +12.9% 45
Guatemala Guatemala 1,273,676,858 -12.3% 109
Hong Kong SAR China Hong Kong SAR China 80,611,027,940 +26.5% 35
Honduras Honduras -563,681,642 -12.2% 125
Croatia Croatia 18,863,056,069 +4.21% 65
Haiti Haiti -1,389,087,549 +9.5% 127
Hungary Hungary 65,024,659,719 -0.259% 40
Indonesia Indonesia 514,800,085,261 -1.51% 9
India India 1,109,978,752,749 +3.39% 3
Ireland Ireland 340,258,401,365 +3.52% 18
Iran Iran 159,885,213,150 +7.3% 23
Iraq Iraq 107,568,866,039 -6.28% 32
Iceland Iceland 8,507,171,820 +5.41% 78
Israel Israel 139,975,977,650 -5.57% 25
Italy Italy 584,725,308,637 +4.17% 7
Kenya Kenya 16,186,555,292 +34.5% 69
Cambodia Cambodia 15,947,498,535 +12.1% 70
Libya Libya 14,253,649,677 -2.13% 71
Sri Lanka Sri Lanka 24,081,807,656 +28.3% 54
Lithuania Lithuania 21,719,731,633 +5.35% 58
Luxembourg Luxembourg 44,669,674,176 +5.27% 43
Latvia Latvia 8,090,591,599 -8.9% 80
Macao SAR China Macao SAR China 29,527,807,664 +14.8% 49
Morocco Morocco 32,012,206,504 +7.96% 46
Moldova Moldova -856,834,300 +39.1% 126
Madagascar Madagascar 2,593,033,596 +27.8% 102
Mexico Mexico 343,307,869,365 +0.426% 16
North Macedonia North Macedonia 2,552,956,093 -2.43% 104
Mali Mali 3,984,909,356 +12.1% 95
Malta Malta 8,801,553,513 +8.4% 77
Montenegro Montenegro 472,723,713 -29.9% 112
Mongolia Mongolia 7,998,829,946 -7.34% 81
Mozambique Mozambique 3,121,809,525 +210% 99
Mauritius Mauritius 2,496,882,721 +11.8% 105
Malaysia Malaysia 114,757,328,807 +4.14% 29
Namibia Namibia -97,256,761 -117% 121
Niger Niger 5,669,811,333 +50.1% 89
Nicaragua Nicaragua 1,397,158,130 -11.3% 107
Netherlands Netherlands 385,246,268,340 +7.21% 13
Norway Norway 183,372,469,950 -4.4% 21
Nepal Nepal 2,670,428,585 -9.91% 101
Pakistan Pakistan 23,367,022,625 +8.35% 56
Peru Peru 72,360,433,582 +19.6% 36
Philippines Philippines 43,143,023,479 +6.6% 44
Poland Poland 198,145,189,024 +4.2% 20
Puerto Rico Puerto Rico 19,884,700,000 +15.9% 64
Portugal Portugal 67,610,446,793 +7.91% 39
Paraguay Paraguay 9,072,980,063 -3.84% 76
Palestinian Territories Palestinian Territories -2,222,000,000 -35.3% 129
Romania Romania 69,665,448,852 -5.37% 37
Russia Russia 697,306,018,731 +2.68% 4
Rwanda Rwanda 2,574,251,397 +95.7% 103
Saudi Arabia Saudi Arabia 416,488,266,667 -3.77% 12
Sudan Sudan 1,396,307,990 +82.7% 108
Senegal Senegal 5,744,282,711 +11.8% 88
Singapore Singapore 317,029,964,086 +7.38% 19
Sierra Leone Sierra Leone 520,611,396 -1.54% 111
El Salvador El Salvador 426,480,000 -28.6% 113
Somalia Somalia -3,827,145,110 +13.1% 130
Serbia Serbia 17,361,012,750 +5.28% 67
Slovakia Slovakia 28,746,424,409 +0.649% 50
Slovenia Slovenia 20,108,123,399 +1.57% 63
Sweden Sweden 177,060,122,346 +4.69% 22
Seychelles Seychelles -18,708,090 -113% 120
Chad Chad 6,179,395,298 +17.1% 85
Togo Togo 852,031,016 -0.507% 110
Thailand Thailand 132,066,640,641 -1.17% 27
Tunisia Tunisia 2,795,696,921 +163% 100
Turkey Turkey 341,559,582,343 +11% 17
Tanzania Tanzania 29,867,347,811 +1.77% 48
Uganda Uganda 12,750,225,914 +38.9% 72
Ukraine Ukraine -552,300,117 -89.3% 124
Uruguay Uruguay 16,721,248,393 +2.56% 68
United States United States 5,442,862,000,000 +5.2% 1
Uzbekistan Uzbekistan 20,809,681,906 +18.8% 60
Samoa Samoa 11,315,667 -121% 119
Kosovo Kosovo 376,606,910 +9.86% 114
South Africa South Africa 63,725,622,989 +2.98% 41
Zimbabwe Zimbabwe -1,764,816,180 -158% 128

                    
# 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 = 'NY.GDS.TOTL.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 <- 'NY.GDS.TOTL.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))