S&P Global Equity Indices (annual % change)

Source: worldbank.org, 01.09.2025

Year: 2022

Flag Country Value Value change, % Rank
United Arab Emirates United Arab Emirates -6.64 -115% 23
Argentina Argentina -30.4 +70.1% 70
Australia Australia -13.8 -262% 40
Austria Austria -25.1 -213% 61
Belgium Belgium -19.1 -771% 50
Bangladesh Bangladesh -25.1 -222% 62
Bulgaria Bulgaria -4.95 -120% 20
Bahrain Bahrain 5.53 -80.8% 7
Brazil Brazil -4.44 -82.5% 19
Botswana Botswana 1.54 -280% 10
Canada Canada -14.8 -165% 43
Switzerland Switzerland -19.8 -220% 54
Chile Chile 15.4 -186% 5
China China -23.6 +14.4% 58
Côte d’Ivoire Côte d’Ivoire -8.22 -142% 27
Colombia Colombia -17.2 +7.14% 46
Cyprus Cyprus -20 -156% 55
Czechia Czechia -18 -141% 48
Germany Germany -12.3 -178% 37
Denmark Denmark -7.95 -151% 26
Egypt Egypt -22.3 -263% 56
Spain Spain -11 +6,428% 34
Estonia Estonia -22.8 -151% 57
Finland Finland -19.5 -267% 53
France France -9.5 -133% 31
United Kingdom United Kingdom 0.91 -93.6% 11
Ghana Ghana -46.4 -228% 77
Greece Greece -0.828 -109% 13
Hong Kong SAR China Hong Kong SAR China -9.65 +32.5% 32
Croatia Croatia -12.7 -355% 38
Hungary Hungary -33.5 -441% 73
Indonesia Indonesia -7.47 +318% 25
India India -8.75 -129% 29
Ireland Ireland -26.8 -291% 64
Israel Israel -29.1 -247% 67
Italy Italy -19.4 -230% 51
Jamaica Jamaica -14.5 +735% 42
Jordan Jordan 11.6 -46.8% 6
Japan Japan -9.37 -291% 30
Kazakhstan Kazakhstan -19.1 -132% 49
Kenya Kenya -26.7 -323% 63
South Korea South Korea -31.4 +351% 71
Kuwait Kuwait 4.05 -85.3% 8
Lebanon Lebanon 61.9 -21.6% 2
Sri Lanka Sri Lanka -62.4 -278% 80
Lithuania Lithuania -11.5 -160% 36
Luxembourg Luxembourg -30.4 -320% 69
Morocco Morocco -30 -348% 68
Mexico Mexico -3.48 -121% 18
Mauritius Mauritius -5.94 -135% 21
Malaysia Malaysia -10.9 +32% 33
Namibia Namibia -3.32 -121% 17
Nigeria Nigeria -13.4 -7,593% 39
Netherlands Netherlands -27.9 -205% 66
Norway Norway -14.3 -194% 41
New Zealand New Zealand -24.9 +109% 60
Oman Oman 19.1 +19.3% 4
Pakistan Pakistan -32 +114% 72
Panama Panama -0.411 -105% 12
Peru Peru 3.64 -120% 9
Philippines Philippines -16 +355% 45
Poland Poland -27.1 -320% 65
Portugal Portugal -3.08 +205% 15
Qatar Qatar -11.3 -192% 35
Romania Romania -17.5 -214% 47
Russia Russia -54.6 -462% 78
Saudi Arabia Saudi Arabia -8.5 -127% 28
Singapore Singapore -15.1 -264% 44
Slovakia Slovakia -34.3 +21.1% 74
Slovenia Slovenia -23.9 -180% 59
Sweden Sweden -35.1 -321% 75
Thailand Thailand -1.01 -151% 14
Trinidad & Tobago Trinidad & Tobago -6.34 -131% 22
Tunisia Tunisia -3.14 -60.2% 16
Turkey Turkey 106 -454% 1
Ukraine Ukraine -58.3 -545% 79
United States United States -19.4 -172% 52
Vietnam Vietnam -46.1 -224% 76
South Africa South Africa -7.15 -232% 24
Zambia Zambia 23.8 -82.5% 3

                    
# 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 = 'CM.MKT.INDX.ZG'

# 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 <- 'CM.MKT.INDX.ZG'

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