Gross fixed capital formation (% of GDP)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 25 +5.14% 31
Albania Albania 23.4 -2.76% 46
Argentina Argentina 15.8 -14.7% 107
Armenia Armenia 21.7 +3.93% 67
Australia Australia 24.3 +4.18% 37
Austria Austria 24.3 -2.28% 35
Azerbaijan Azerbaijan 16.8 -3.47% 101
Belgium Belgium 24.4 -0.198% 33
Benin Benin 34.7 +1.59% 4
Burkina Faso Burkina Faso 16.5 -3.98% 103
Bangladesh Bangladesh 30.7 -0.81% 10
Bulgaria Bulgaria 17.9 -4.05% 93
Bahamas Bahamas 25.7 +18.3% 28
Belarus Belarus 23.8 +5.52% 40
Bermuda Bermuda 11.3 +0.754% 120
Brazil Brazil 17 +3.79% 99
Brunei Brunei 28.2 -4.3% 18
Botswana Botswana 28.5 +11.1% 17
Central African Republic Central African Republic 15.4 +5.58% 109
Canada Canada 22.7 -0.84% 53
Switzerland Switzerland 25.1 -2.98% 30
Chile Chile 23.5 -3.11% 45
Côte d’Ivoire Côte d’Ivoire 24.5 +5.79% 32
Cameroon Cameroon 21.4 +11.8% 72
Congo - Kinshasa Congo - Kinshasa 32.9 +4.41% 5
Congo - Brazzaville Congo - Brazzaville 26.5 +6.56% 21
Colombia Colombia 16.5 +0.0233% 102
Comoros Comoros 11.7 +0.0252% 118
Costa Rica Costa Rica 15.8 -2.19% 108
Cyprus Cyprus 20.5 -4.35% 79
Czechia Czechia 26.2 -4.15% 24
Germany Germany 20.9 -2.99% 75
Djibouti Djibouti 26.3 +7.24% 23
Denmark Denmark 22.2 -1.6% 59
Dominican Republic Dominican Republic 26.1 -9.88% 26
Ecuador Ecuador 18.4 -7.26% 91
Egypt Egypt 11.7 -22.7% 119
Spain Spain 19.5 -0.89% 87
Estonia Estonia 26.1 -6.52% 27
Ethiopia Ethiopia 20.5 -7.54% 80
Finland Finland 21.5 -8.14% 71
France France 22.3 -3.34% 56
Gabon Gabon 18.1 +3.32% 92
United Kingdom United Kingdom 17.4 -1.3% 96
Georgia Georgia 22 +2.75% 62
Ghana Ghana 9.8 +1.51% 123
Guinea Guinea 32.1 +31.1% 6
Gambia Gambia 39 +42.9% 2
Guinea-Bissau Guinea-Bissau 22.8 +5.89% 50
Equatorial Guinea Equatorial Guinea 9.07 -2.57% 124
Greece Greece 15.3 +0.724% 110
Guatemala Guatemala 16.1 -1.39% 106
Hong Kong SAR China Hong Kong SAR China 16.2 -4.33% 105
Honduras Honduras 23.9 +0.717% 39
Croatia Croatia 23.7 +5.37% 41
Haiti Haiti 9.94 -28.3% 122
Hungary Hungary 23.4 -8.65% 47
Indonesia Indonesia 29.1 -0.0243% 14
India India 29.6 -2.69% 12
Ireland Ireland 17.2 -25.8% 97
Iran Iran 26.7 -0.309% 20
Iraq Iraq 20.6 +34.7% 77
Iceland Iceland 26.4 +6.4% 22
Israel Israel 22.7 -6.86% 52
Italy Italy 22 -2.46% 63
Kenya Kenya 17.7 +2.5% 95
Cambodia Cambodia 31.6 -3.35% 8
Libya Libya 14.8 -9.97% 111
Sri Lanka Sri Lanka 18.8 +5.34% 89
Lithuania Lithuania 22.5 -4.99% 55
Luxembourg Luxembourg 14.3 -10.9% 115
Latvia Latvia 23.1 -6.4% 48
Macao SAR China Macao SAR China 13.8 -5.77% 116
Morocco Morocco 26.1 +2.86% 25
Moldova Moldova 20 +2.82% 84
Madagascar Madagascar 22.6 +13.9% 54
Mexico Mexico 24.2 +0.977% 38
Mali Mali 21.6 -0.353% 68
Malta Malta 17.9 -5.3% 94
Montenegro Montenegro 20.2 +3.11% 82
Mongolia Mongolia 26.8 +5.83% 19
Mauritius Mauritius 21 +3.62% 74
Malaysia Malaysia 20.6 +6.84% 78
Namibia Namibia 23.7 -9.34% 42
Niger Niger 18.7 -12.2% 90
Nicaragua Nicaragua 22.9 +6.83% 49
Netherlands Netherlands 19.7 -1.81% 86
Norway Norway 21.9 +0.996% 65
Nepal Nepal 24.3 -1.06% 36
Pakistan Pakistan 11.2 -8.84% 121
Peru Peru 20.8 -1.96% 76
Philippines Philippines 23.6 -0.271% 44
Poland Poland 16.9 -5.68% 100
Puerto Rico Puerto Rico 14.6 +3.95% 112
Portugal Portugal 19.8 -1.26% 85
Paraguay Paraguay 21 +1.57% 73
Palestinian Territories Palestinian Territories 21.8 -9.17% 66
Romania Romania 25.7 -4.87% 29
Russia Russia 22.1 +0.606% 61
Rwanda Rwanda 29.1 +9.19% 15
Saudi Arabia Saudi Arabia 28.7 +2.86% 16
Sudan Sudan 2.87 +32.2% 126
Senegal Senegal 32.1 -9.38% 7
Singapore Singapore 21.9 -2.22% 64
Sierra Leone Sierra Leone 29.5 +48.9% 13
El Salvador El Salvador 22.2 +1.03% 60
Somalia Somalia 22.7 +1.5% 51
Serbia Serbia 23.6 +1.08% 43
Slovakia Slovakia 20.3 -3.55% 81
Slovenia Slovenia 20.1 -5.99% 83
Sweden Sweden 24.4 -2.48% 34
Seychelles Seychelles 17.2 -16.5% 98
Chad Chad 14.4 -3.33% 114
Togo Togo 22.3 -2.89% 57
Thailand Thailand 22.2 -2.98% 58
Tunisia Tunisia 13.4 -15.1% 117
Turkey Turkey 31 -2.69% 9
Tanzania Tanzania 41.4 -3.22% 1
Uganda Uganda 21.5 -2.42% 70
Ukraine Ukraine 18.9 -5.07% 88
Uruguay Uruguay 16.2 -5.57% 104
United States United States 21.6 +0.819% 69
Uzbekistan Uzbekistan 37.1 +14.3% 3
Samoa Samoa 30.5 -11.6% 11
South Africa South Africa 14.5 -2.78% 113
Zimbabwe Zimbabwe 3.57 -70.7% 125

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