Ores and metals imports (% of merchandise imports)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Albania Albania 1.27 -28.6% 60
Argentina Argentina 3.31 +13.5% 27
Armenia Armenia 5.71 +73.7% 15
Antigua & Barbuda Antigua & Barbuda 0.973 -11.2% 70
Australia Australia 1.35 -1.27% 58
Azerbaijan Azerbaijan 1.04 -1.02% 65
Belgium Belgium 4.59 +10.5% 19
Burkina Faso Burkina Faso 0.378 -27% 85
Bulgaria Bulgaria 9.83 +12.9% 4
Bosnia & Herzegovina Bosnia & Herzegovina 5.04 -8.05% 16
Belize Belize 0.554 +1.34% 83
Bolivia Bolivia 0.882 +19.2% 73
Brazil Brazil 2.88 -1.71% 32
Barbados Barbados 0.737 +14.2% 78
Canada Canada 3.25 -2.34% 28
Switzerland Switzerland 2.25 +4.17% 43
Chile Chile 1.89 +16.5% 47
China China 15.1 +3.48% 1
Cyprus Cyprus 0.748 +11.8% 76
Czechia Czechia 2.79 -4.36% 34
Germany Germany 3.92 -5.26% 23
Denmark Denmark 2.08 +9.53% 45
Dominican Republic Dominican Republic 1.11 -12.7% 63
Ecuador Ecuador 1.12 -10.9% 61
Egypt Egypt 7.1 -0.608% 8
Spain Spain 3.56 +7.69% 26
Estonia Estonia 1.55 +2.78% 56
Finland Finland 7.2 +7.47% 6
Fiji Fiji 0.999 +26.3% 67
United Kingdom United Kingdom 2.7 -6.85% 36
Georgia Georgia 1.64 -42.1% 50
Greece Greece 4.15 +14.1% 22
Grenada Grenada 0.999 -16.3% 68
Guatemala Guatemala 1.07 -2.74% 64
Guyana Guyana 1.58 +1.86% 53
Hong Kong SAR China Hong Kong SAR China 1.6 +7.61% 51
Croatia Croatia 2.94 -2.16% 31
Hungary Hungary 2.75 +1.58% 35
India India 6.86 +13.7% 10
Ireland Ireland 0.977 -21.5% 69
Iceland Iceland 8.91 +10.8% 5
Israel Israel 1.39 +0.973% 57
Italy Italy 4.81 +1.15% 18
Japan Japan 7.2 +2.24% 7
Kyrgyzstan Kyrgyzstan 0.637 +20% 81
South Korea South Korea 6.68 -0.253% 11
Sri Lanka Sri Lanka 1.58 +14.5% 54
Lithuania Lithuania 1.73 +26.5% 49
Luxembourg Luxembourg 5.75 +8.49% 14
Latvia Latvia 1.27 +0.668% 59
Macao SAR China Macao SAR China 0.287 -8.47% 86
Moldova Moldova 0.743 -0.801% 77
Maldives Maldives 2.83 -27.2% 33
Mexico Mexico 2.6 +5.98% 40
North Macedonia North Macedonia 11.2 -11.7% 2
Malta Malta 0.699 -17.9% 79
Myanmar (Burma) Myanmar (Burma) 0.928 +4.46% 72
Montenegro Montenegro 1.6 -26.8% 52
Mauritius Mauritius 1.03 +5.05% 66
Malaysia Malaysia 5.03 -6.97% 17
Namibia Namibia 9.92 +66.4% 3
Netherlands Netherlands 2.62 +0.85% 38
Norway Norway 6.22 -1.67% 12
New Zealand New Zealand 1.79 +5.92% 48
Pakistan Pakistan 3.83 +4.8% 25
Panama Panama 0.651 +10.8% 80
Philippines Philippines 4.16 -3.86% 21
Poland Poland 3.13 -4.23% 30
Portugal Portugal 2.6 -2.16% 39
Paraguay Paraguay 1.56 +24.8% 55
French Polynesia French Polynesia 0.421 -10.1% 84
Romania Romania 2.44 +2.37% 42
El Salvador El Salvador 0.933 -20.1% 71
Suriname Suriname 0.632 -9.37% 82
Slovakia Slovakia 2.66 +1.79% 37
Slovenia Slovenia 3.23 -15.4% 29
Sweden Sweden 3.87 +18.9% 24
Togo Togo 0.765 -14.4% 75
Thailand Thailand 4.37 +7.92% 20
Trinidad & Tobago Trinidad & Tobago 5.9 +22.6% 13
Turkey Turkey 7.01 +6.35% 9
Ukraine Ukraine 1.11 -5.04% 62
United States United States 2.08 -8.17% 44
Uzbekistan Uzbekistan 1.92 -11.6% 46
South Africa South Africa 2.49 +10.4% 41
Zimbabwe Zimbabwe 0.803 -2.48% 74

                    
# 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 = 'TM.VAL.MMTL.ZS.UN'

# 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 <- 'TM.VAL.MMTL.ZS.UN'

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