Gross capital formation (% of GDP)

Source: worldbank.org, 01.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 25 +5.14% 41
Argentina Argentina 15.7 -18.8% 111
Armenia Armenia 22.2 +4.12% 68
Australia Australia 24.4 +1.74% 45
Austria Austria 22.3 -12.2% 65
Azerbaijan Azerbaijan 21.1 +18.8% 80
Belgium Belgium 24 -5.27% 49
Benin Benin 35.1 +1.54% 5
Burkina Faso Burkina Faso 27.1 +20.2% 26
Bangladesh Bangladesh 30.7 -0.81% 17
Bulgaria Bulgaria 20.4 +3.06% 87
Bahamas Bahamas 26.8 +17.2% 31
Bosnia & Herzegovina Bosnia & Herzegovina 30.8 +16.9% 16
Belarus Belarus 25.8 +4.55% 37
Bermuda Bermuda 11.3 +0.754% 124
Brazil Brazil 16.9 +7.29% 106
Brunei Brunei 28.4 -4.27% 25
Botswana Botswana 36.2 +19.5% 4
Central African Republic Central African Republic 15.4 -35.1% 114
Canada Canada 23.3 -2.62% 56
Switzerland Switzerland 27 +3.85% 28
Chile Chile 23.2 -0.524% 57
Côte d’Ivoire Côte d’Ivoire 24.5 -6.21% 44
Cameroon Cameroon 21.4 +9.54% 75
Congo - Kinshasa Congo - Kinshasa 33.4 +4.5% 8
Congo - Brazzaville Congo - Brazzaville 26.8 +6.48% 30
Colombia Colombia 17.1 +3.94% 105
Comoros Comoros 11.7 -9.84% 123
Cape Verde Cape Verde 16 -17.5% 109
Costa Rica Costa Rica 15.7 +2.7% 112
Cyprus Cyprus 18.9 -8.23% 93
Czechia Czechia 26 -7.05% 35
Germany Germany 21 -2.88% 81
Djibouti Djibouti -3.78 +16.6% 130
Denmark Denmark 21.6 -5.22% 73
Dominican Republic Dominican Republic 27 -2.94% 27
Ecuador Ecuador 18.5 -10.5% 97
Egypt Egypt 13 -21.2% 121
Spain Spain 20.5 -2.52% 85
Estonia Estonia 26.2 -5.46% 34
Ethiopia Ethiopia 20.5 -7.54% 84
Finland Finland 21.7 -5.78% 72
France France 21.9 -5.27% 69
Gabon Gabon 18.1 +3.32% 99
United Kingdom United Kingdom 17.9 +3.94% 100
Georgia Georgia 22.8 -8.73% 59
Ghana Ghana 9.96 +0.573% 125
Guinea Guinea 31.2 +33.1% 15
Gambia Gambia 39 +42.9% 3
Guinea-Bissau Guinea-Bissau 20.9 +10.4% 82
Equatorial Guinea Equatorial Guinea 8.96 -4.32% 127
Greece Greece 18.2 +8.65% 98
Guatemala Guatemala 16.7 +1.26% 108
Hong Kong SAR China Hong Kong SAR China 15.7 -2.44% 110
Honduras Honduras 22.5 +1.38% 62
Croatia Croatia 23.5 +0.956% 53
Haiti Haiti 9.94 -28.3% 126
Hungary Hungary 23.6 -8.79% 52
Indonesia Indonesia 31.4 +3.47% 14
India India 32.6 -2.25% 12
Ireland Ireland 17.4 -33.9% 103
Iran Iran 40 +3.03% 1
Iraq Iraq 29.4 +22% 22
Iceland Iceland 26.6 +4.16% 32
Israel Israel 23.4 -10.3% 55
Italy Italy 22.4 -2.5% 63
Kenya Kenya 16.8 +2.62% 107
Cambodia Cambodia 32.2 -3.33% 13
Libya Libya 14.8 -9.97% 116
Sri Lanka Sri Lanka 27 +9.66% 29
Lithuania Lithuania 20.4 -6.94% 86
Luxembourg Luxembourg 15.2 -12.8% 115
Latvia Latvia 21.2 -13.9% 78
Macao SAR China Macao SAR China 14.5 -6.42% 118
Morocco Morocco 29.9 +3.8% 20
Moldova Moldova 21.1 +5.21% 79
Madagascar Madagascar 22.6 +13.6% 61
Mexico Mexico 24.2 +0.927% 47
North Macedonia North Macedonia 28.4 -4.09% 24
Mali Mali 20.9 -6.51% 83
Malta Malta 18.8 -5.2% 94
Montenegro Montenegro 28.5 +3.4% 23
Mongolia Mongolia 34.6 +2.19% 6
Mozambique Mozambique 24.1 +21.4% 48
Mauritius Mauritius 21.2 +6.57% 76
Malaysia Malaysia 21.9 -2.75% 70
Namibia Namibia 25.6 -8.56% 38
Niger Niger 18.7 -13.9% 95
Nicaragua Nicaragua 24.7 +11.5% 42
Netherlands Netherlands 19.3 -3.37% 92
Norway Norway 24 -0.986% 50
Nepal Nepal 30.4 -2.41% 18
Pakistan Pakistan 12.9 -7.76% 122
Peru Peru 19.4 +1.23% 91
Philippines Philippines 23.7 +1.19% 51
Poland Poland 17.7 -0.0782% 102
Puerto Rico Puerto Rico 14.8 +2.73% 117
Portugal Portugal 20.1 -1.92% 89
Paraguay Paraguay 22.8 +13.3% 58
Palestinian Territories Palestinian Territories 23.5 -8.31% 54
Romania Romania 24.3 -5.72% 46
Russia Russia 26.3 -2.62% 33
Rwanda Rwanda 25.9 +9.87% 36
Saudi Arabia Saudi Arabia 30.1 +3.18% 19
Sudan Sudan 2.87 +32.2% 129
Senegal Senegal 32.9 -21.6% 10
Singapore Singapore 22.2 +4.5% 67
Sierra Leone Sierra Leone 29.5 +49.6% 21
El Salvador El Salvador 20.3 -1.65% 88
Somalia Somalia 22.7 +1.5% 60
Serbia Serbia 25.6 +3.85% 39
Slovakia Slovakia 20.1 +1.34% 90
Slovenia Slovenia 21.2 -4.82% 77
Sweden Sweden 24.6 -0.937% 43
Seychelles Seychelles 17.2 -16.5% 104
Chad Chad 17.8 -3.33% 101
Togo Togo 22.3 -2.89% 66
Thailand Thailand 21.6 -3.95% 74
Tunisia Tunisia 13.4 +71.8% 120
Turkey Turkey 25.5 -14.8% 40
Tanzania Tanzania 39.8 -3.02% 2
Uganda Uganda 22.3 -2.22% 64
Ukraine Ukraine 18.6 +3.17% 96
Uruguay Uruguay 15.6 -11.1% 113
United States United States 21.7 +0.941% 71
Uzbekistan Uzbekistan 33.3 -3.81% 9
Samoa Samoa 32.8 -11.6% 11
Kosovo Kosovo 33.8 -0.438% 7
South Africa South Africa 13.9 -10.3% 119
Zimbabwe Zimbabwe 4.47 -72.5% 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 = 'NE.GDI.TOTL.ZS'

# 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.ZS'

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