Gross fixed capital formation (current US$)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 20,100,497,840 -0.407% 60
Albania Albania 6,356,004,202 +12.2% 90
Argentina Argentina 100,288,864,685 -16.4% 29
Armenia Armenia 5,593,807,450 +11.3% 93
Australia Australia 425,205,956,513 +5.64% 10
Austria Austria 126,929,779,098 -0.382% 22
Azerbaijan Azerbaijan 12,482,764,706 -0.954% 71
Belgium Belgium 162,141,027,171 +2.88% 18
Benin Benin 7,447,076,802 +10.9% 86
Burkina Faso Burkina Faso 3,835,269,390 +9.85% 102
Bangladesh Bangladesh 138,188,871,817 +2.07% 21
Bulgaria Bulgaria 20,125,083,940 +5.14% 59
Bahamas Bahamas 4,076,900,000 +22.6% 100
Belarus Belarus 18,079,060,019 +10.6% 65
Bermuda Bermuda 1,013,300,000 +5.46% 119
Brazil Brazil 371,217,219,098 +3.23% 13
Brunei Brunei 4,354,399,069 -1.97% 97
Botswana Botswana 5,527,869,480 +11.1% 94
Central African Republic Central African Republic 423,984,487 +13.7% 122
Canada Canada 507,892,094,720 +2.26% 7
Switzerland Switzerland 234,652,590,132 +1.59% 17
Chile Chile 77,577,608,120 -4.63% 35
Côte d’Ivoire Côte d’Ivoire 21,186,737,759 +15% 57
Cameroon Cameroon 10,973,360,192 +16.4% 74
Congo - Kinshasa Congo - Kinshasa 23,304,564,460 +10.2% 53
Congo - Brazzaville Congo - Brazzaville 4,171,980,388 +9.34% 98
Colombia Colombia 69,137,943,688 +14.3% 36
Comoros Comoros 181,426,032 +8.11% 125
Costa Rica Costa Rica 15,089,704,083 +7.82% 66
Cyprus Cyprus 7,454,518,395 +2.56% 84
Czechia Czechia 90,283,802,701 -3.64% 33
Germany Germany 971,923,541,914 -0.112% 3
Djibouti Djibouti 1,074,855,525 +11.9% 118
Denmark Denmark 95,381,315,614 +3.81% 32
Dominican Republic Dominican Republic 32,463,879,925 -7.01% 51
Ecuador Ecuador 22,953,050,700 -4.56% 54
Egypt Egypt 45,512,764,932 -24% 44
Spain Spain 336,528,323,441 +5.39% 15
Estonia Estonia 11,164,260,970 -3.18% 73
Finland Finland 64,347,518,867 -6.62% 38
France France 705,805,366,821 +0.148% 4
Gabon Gabon 3,780,342,008 +7.5% 103
United Kingdom United Kingdom 634,121,617,947 +6.72% 5
Georgia Georgia 7,447,418,926 +12.8% 85
Ghana Ghana 8,113,911,061 +4.38% 82
Guinea Guinea 8,139,967,068 +48.3% 81
Gambia Gambia 977,561,341 +49.5% 120
Guinea-Bissau Guinea-Bissau 484,005,138 +8.03% 121
Equatorial Guinea Equatorial Guinea 1,158,087,491 +0.814% 117
Greece Greece 39,279,327,440 +6.37% 48
Guatemala Guatemala 18,240,788,445 +6.95% 64
Hong Kong SAR China Hong Kong SAR China 65,990,904,726 +2.21% 37
Honduras Honduras 8,875,192,435 +8.74% 79
Croatia Croatia 21,894,759,020 +15.5% 56
Haiti Haiti 2,507,120,060 -8.83% 111
Hungary Hungary 52,111,801,180 -4.86% 43
Indonesia Indonesia 406,959,842,018 +1.81% 12
India India 1,158,447,492,084 +4.64% 2
Ireland Ireland 99,264,463,361 -22.4% 30
Iran Iran 116,796,555,069 +7.64% 26
Iraq Iraq 57,554,450,995 +40.1% 42
Iceland Iceland 8,838,337,127 +13.2% 80
Israel Israel 122,614,875,707 -1.73% 23
Italy Italy 521,154,505,994 +0.427% 6
Kenya Kenya 21,989,457,231 +18.1% 55
Cambodia Cambodia 14,640,645,704 +5.82% 67
Libya Libya 6,919,569,687 -6.9% 88
Sri Lanka Sri Lanka 18,598,173,511 +24.5% 62
Lithuania Lithuania 19,096,388,821 +1.06% 61
Luxembourg Luxembourg 13,361,394,825 -5.2% 69
Latvia Latvia 10,053,926,943 -4.31% 77
Macao SAR China Macao SAR China 6,903,716,154 +3.24% 89
Morocco Morocco 40,377,376,256 +9.99% 47
Moldova Moldova 3,637,428,703 +12% 105
Madagascar Madagascar 3,938,159,103 +25% 101
Mexico Mexico 447,709,317,111 +4.29% 9
Mali Mali 5,745,725,502 +7.61% 92
Malta Malta 4,360,356,646 +3.71% 96
Montenegro Montenegro 1,633,089,347 +10.5% 114
Mongolia Mongolia 6,321,609,387 +22.8% 91
Mauritius Mauritius 3,133,340,910 +9.88% 107
Malaysia Malaysia 86,741,858,441 +12.8% 34
Namibia Namibia 3,163,826,307 -2.3% 106
Niger Niger 3,649,703,592 +2.78% 104
Nicaragua Nicaragua 4,512,773,661 +18.2% 95
Netherlands Netherlands 242,233,501,765 +4.42% 16
Norway Norway 105,783,326,871 +1.16% 28
Nepal Nepal 10,440,548,230 +3.44% 75
Pakistan Pakistan 41,881,011,672 +0.658% 46
Peru Peru 60,096,278,717 +6.22% 40
Philippines Philippines 108,805,587,779 +5.33% 27
Poland Poland 154,448,006,837 +6.19% 19
Puerto Rico Puerto Rico 18,316,600,000 +10.5% 63
Portugal Portugal 61,185,179,806 +5.22% 39
Paraguay Paraguay 9,321,413,308 +4.73% 78
Palestinian Territories Palestinian Territories 2,995,600,000 -30.2% 108
Romania Romania 98,231,732,777 +3.8% 31
Russia Russia 481,132,998,139 +5.58% 8
Rwanda Rwanda 4,149,120,963 +8.58% 99
Saudi Arabia Saudi Arabia 354,934,666,667 +4.46% 14
Sudan Sudan 1,433,914,068 +65.4% 116
Senegal Senegal 10,347,308,126 -4.74% 76
Singapore Singapore 119,858,512,700 +5.89% 24
Sierra Leone Sierra Leone 2,226,282,571 +75.2% 112
El Salvador El Salvador 7,846,880,000 +5.53% 83
Somalia Somalia 2,750,440,440 +12.1% 110
Serbia Serbia 21,047,098,466 +10.7% 58
Slovakia Slovakia 28,832,469,327 +2.12% 52
Slovenia Slovenia 14,537,887,193 -1.46% 68
Sweden Sweden 148,813,881,869 +1.62% 20
Seychelles Seychelles 372,099,665 -17.3% 123
Chad Chad 2,968,824,362 +4.35% 109
Togo Togo 2,212,640,231 +5.1% 113
Thailand Thailand 117,113,620,063 -1.01% 25
Tunisia Tunisia 7,132,384,812 -5.9% 87
Turkey Turkey 410,189,478,682 +15.1% 11
Tanzania Tanzania 32,575,570,126 -3.57% 50
Uganda Uganda 11,561,741,788 +7.35% 72
Ukraine Ukraine 36,012,353,580 -0.0797% 49
Uruguay Uruguay 13,146,489,946 -1.98% 70
United States United States 6,293,963,000,000 +6.14% 1
Uzbekistan Uzbekistan 42,601,435,126 +28% 45
Samoa Samoa 325,966,364 +0.65% 124
South Africa South Africa 58,116,496,527 +2.22% 41
Zimbabwe Zimbabwe 1,578,761,190 -63.3% 115

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