Gross capital formation (constant 2015 US$)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 32,148,441,317 +7.22% 46
Argentina Argentina 88,619,679,353 -17.8% 28
Armenia Armenia 4,049,225,336 +11.4% 94
Austria Austria 92,892,883,431 -7.41% 26
Belgium Belgium 124,142,534,781 -3.01% 20
Benin Benin 5,391,450,462 +10.5% 90
Burkina Faso Burkina Faso 4,954,296,325 +20% 91
Bangladesh Bangladesh 105,571,257,263 +3.27% 22
Bulgaria Bulgaria 12,794,743,267 +4.07% 64
Bahamas Bahamas 3,742,363,500 +19.8% 96
Bosnia & Herzegovina Bosnia & Herzegovina 6,593,283,553 +13.6% 79
Belarus Belarus 16,082,385,804 +7.22% 58
Bermuda Bermuda 872,167,190 +3.72% 112
Brazil Brazil 361,494,202,595 +10.8% 11
Brunei Brunei 4,027,404,332 -2.35% 95
Botswana Botswana 6,213,476,138 +14.6% 82
Central African Republic Central African Republic 405,659,163 +22.6% 116
Canada Canada 395,576,766,245 -1.99% 10
Switzerland Switzerland 200,771,276,836 +2.41% 16
Chile Chile 68,306,607,316 +1.02% 32
China China 7,240,776,590,390 +3.14% 1
Côte d’Ivoire Côte d’Ivoire 24,631,251,258 +9.32% 50
Cameroon Cameroon 8,908,504,550 +22.2% 74
Congo - Kinshasa Congo - Kinshasa 75,185,050,962 +19.1% 31
Colombia Colombia 65,365,160,967 +7.59% 33
Comoros Comoros 163,718,037 +3.09% 120
Cape Verde Cape Verde 537,972,108 +1.22% 115
Costa Rica Costa Rica 17,539,424,423 +9.64% 56
Cyprus Cyprus 5,416,149,110 -9.5% 89
Czechia Czechia 61,716,060,800 -4.27% 34
Germany Germany 751,613,168,857 -2.54% 4
Djibouti Djibouti -759,902,603 +43.4% 121
Denmark Denmark 75,246,605,490 -1.77% 30
Dominican Republic Dominican Republic 29,337,700,425 +2.56% 49
Ecuador Ecuador 22,600,541,962 -5.41% 52
Egypt Egypt 46,643,502,755 -6.14% 41
Spain Spain 282,575,645,355 +1.85% 13
Estonia Estonia 7,599,547,233 -2.67% 77
Ethiopia Ethiopia 41,867,426,444 +7.21% 43
Finland Finland 52,027,278,870 -4.75% 36
France France 578,584,851,061 -3.29% 5
Gabon Gabon 9,476,842,471 +7.61% 72
United Kingdom United Kingdom 562,812,395,238 +7.97% 6
Georgia Georgia 5,450,066,254 +2.19% 88
Ghana Ghana 13,885,648,062 +13% 61
Guinea Guinea 5,596,087,534 +47.9% 87
Gambia Gambia 762,021,286 +7.12% 113
Guinea-Bissau Guinea-Bissau 246,926,344 +34.7% 119
Equatorial Guinea Equatorial Guinea 942,684,151 -1.47% 111
Greece Greece 43,733,053,061 +23.1% 42
Guatemala Guatemala 14,549,300,077 +6.9% 60
Honduras Honduras 6,199,792,589 +15.3% 83
Croatia Croatia 14,813,732,401 +9.02% 59
Haiti Haiti 663,318,395 -36.3% 114
Hungary Hungary 34,047,655,186 -6.47% 45
Indonesia Indonesia 411,925,437,437 +7.47% 8
India India 1,184,508,995,311 +5.84% 3
Ireland Ireland 79,493,139,540 -33.8% 29
Iran Iran 218,214,973,864 +5.91% 15
Iraq Iraq 31,460,086,627 +14.4% 47
Iceland Iceland 5,939,727,814 +5.2% 84
Israel Israel 95,544,624,012 -9.43% 25
Italy Italy 453,222,784,593 -0.22% 7
Kenya Kenya 18,692,383,703 +2.19% 55
Cambodia Cambodia 12,947,544,115 +1.04% 63
Libya Libya 7,322,130,226 -8.36% 78
Sri Lanka Sri Lanka 23,091,376,124 +21.1% 51
Lithuania Lithuania 11,516,410,621 +3.21% 66
Luxembourg Luxembourg 10,409,591,878 -8.37% 70
Latvia Latvia 9,005,139,320 -11.7% 73
Macao SAR China Macao SAR China 6,286,756,816 +3.69% 80
Morocco Morocco 41,676,487,032 +11.2% 44
Moldova Moldova 2,346,579,630 -3.47% 106
Madagascar Madagascar 2,760,453,418 +9.02% 104
Mexico Mexico 322,132,063,473 +3.21% 12
North Macedonia North Macedonia 3,603,538,419 +8.88% 98
Mali Mali 5,928,901,243 +0.27% 85
Malta Malta 3,560,568,125 +2.39% 99
Montenegro Montenegro 1,375,732,370 +6.27% 110
Mongolia Mongolia 7,894,142,403 +22.2% 75
Mozambique Mozambique 6,243,938,012 +26.7% 81
Malaysia Malaysia 92,430,994,901 +6.02% 27
Namibia Namibia 3,335,832,165 -5.9% 100
Niger Niger 4,491,297,242 +3.54% 93
Nicaragua Nicaragua 4,595,181,451 +28.7% 92
Netherlands Netherlands 181,130,070,063 -2.83% 17
Norway Norway 111,276,842,013 -4.4% 21
Nepal Nepal 12,053,554,722 +0.494% 65
Pakistan Pakistan 47,367,431,218 -2.64% 39
Peru Peru 47,582,556,631 +8.71% 38
Philippines Philippines 103,662,695,120 +7.69% 23
Poland Poland 124,586,205,067 +3.96% 19
Portugal Portugal 46,793,052,251 +2.31% 40
Paraguay Paraguay 10,622,794,794 +11.9% 69
Palestinian Territories Palestinian Territories 2,851,200,000 -30% 103
Romania Romania 61,662,200,168 -0.489% 35
Russia Russia 408,518,012,449 +2.1% 9
Rwanda Rwanda 3,281,312,629 +16% 101
Saudi Arabia Saudi Arabia 252,499,487,633 -0.228% 14
Senegal Senegal 9,759,272,519 -16.7% 71
Singapore Singapore 97,583,747,046 +10.1% 24
Sierra Leone Sierra Leone 1,867,948,748 +22.4% 109
El Salvador El Salvador 5,894,189,127 -0.868% 86
Somalia Somalia 2,225,193,346 +9.79% 107
Serbia Serbia 16,490,376,673 +16.2% 57
Slovakia Slovakia 21,728,619,298 +6.8% 53
Slovenia Slovenia 11,418,817,767 -2.37% 67
Sweden Sweden 139,580,136,209 +0.247% 18
Seychelles Seychelles 335,107,371 -16.7% 117
Chad Chad 3,274,014,494 +2.97% 102
Togo Togo 2,131,956,753 +2.66% 108
Tunisia Tunisia 7,787,948,919 +8.03% 76
Tanzania Tanzania 30,179,453,449 +5.58% 48
Uganda Uganda 13,121,361,648 +5.56% 62
Ukraine Ukraine 21,225,954,999 +8.88% 54
Uruguay Uruguay 10,862,557,428 -7.12% 68
United States United States 4,996,395,152,625 +4.53% 2
Samoa Samoa 306,224,088 -6.04% 118
Kosovo Kosovo 2,560,558,779 +5.91% 105
South Africa South Africa 50,366,913,594 -9.75% 37
Zimbabwe Zimbabwe 3,670,375,904 +0.485% 97

                    
# 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 = 'NE.GDI.TOTL.KD'

# 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 <- 'NE.GDI.TOTL.KD'

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