Container port traffic (TEU: 20 foot equivalent units)

Source: worldbank.org, 01.09.2025

Year: 2022

Flag Country Value Value change, % Rank
Angola Angola 654,590 +8.2% 70
United Arab Emirates United Arab Emirates 20,300,000 +5.83% 8
Argentina Argentina 1,667,161 -7.32% 50
Australia Australia 9,375,992 +1.32% 22
Belgium Belgium 12,303,822 -6.04% 16
Bangladesh Bangladesh 3,200,236 -2.19% 39
Bulgaria Bulgaria 254,854 +3.95% 81
Bahamas Bahamas 1,724,000 -3.84% 49
Brazil Brazil 11,683,239 -1% 17
Barbados Barbados 97,000 +3.3% 86
Canada Canada 7,010,704 -2.22% 28
Chile Chile 4,158,260 -4.09% 34
China China 268,990,000 +4.69% 1
Congo - Brazzaville Congo - Brazzaville 999,999 -0.372% 63
Colombia Colombia 4,480,670 -8.59% 33
Cape Verde Cape Verde 82,871 +3.91% 88
Costa Rica Costa Rica 1,594,323 +4.67% 53
Cuba Cuba 261,080 +5.98% 80
Curaçao Curaçao 96,000 +3.63% 87
Cayman Islands Cayman Islands 40,829 -34.1% 89
Cyprus Cyprus 371,740 +16.5% 78
Germany Germany 13,733,867 -6.64% 13
Djibouti Djibouti 635,000 -8.24% 71
Denmark Denmark 1,079,649 +2.38% 60
Dominican Republic Dominican Republic 2,043,326 -6.47% 47
Ecuador Ecuador 2,682,600 +1.92% 45
Egypt Egypt 7,765,482 +7.46% 27
Spain Spain 17,161,676 -3.11% 10
Estonia Estonia 288,456 +27.1% 79
Finland Finland 1,446,004 +2.62% 56
France France 6,467,242 +1.07% 30
United Kingdom United Kingdom 9,738,676 -5.36% 21
Ghana Ghana 1,244,245 -22.5% 57
Greece Greece 5,166,629 -15% 32
Guatemala Guatemala 1,660,504 -4.32% 51
Hong Kong SAR China Hong Kong SAR China 16,573,000 -6.75% 11
Honduras Honduras 923,321 +11.9% 65
Croatia Croatia 544,015 +43.3% 72
Indonesia Indonesia 12,380,584 -4.11% 14
India India 19,717,168 +0.794% 9
Ireland Ireland 1,154,803 +1.03% 58
Israel Israel 2,951,000 -4.06% 42
Italy Italy 11,577,495 +2.43% 18
Jamaica Jamaica 2,137,500 +8.21% 46
Japan Japan 22,515,870 +0.724% 6
Kenya Kenya 1,450,000 +1.01% 55
South Korea South Korea 28,502,044 -4.31% 4
Sri Lanka Sri Lanka 6,860,000 -5.38% 29
Lithuania Lithuania 1,047,941 +57.2% 61
Latvia Latvia 471,684 +8.65% 74
Morocco Morocco 8,835,181 +4.47% 24
Mexico Mexico 8,307,884 +5.8% 26
Malta Malta 2,993,799 -2.67% 41
Myanmar (Burma) Myanmar (Burma) 846,426 +22% 66
Mozambique Mozambique 420,500 -4.56% 76
Mauritius Mauritius 407,825 -6.55% 77
Malaysia Malaysia 27,293,935 -3.42% 5
Namibia Namibia 160,368 -3.71% 83
Nigeria Nigeria 1,566,109 0% 54
Nicaragua Nicaragua 153,390 -11.1% 84
Netherlands Netherlands 14,929,333 -5.4% 12
Norway Norway 933,300 +5.91% 64
New Zealand New Zealand 3,426,030 +5.44% 37
Oman Oman 5,228,456 -0.134% 31
Pakistan Pakistan 3,383,580 -4.63% 38
Panama Panama 8,518,425 -1.22% 25
Peru Peru 2,865,239 -0.309% 43
Philippines Philippines 9,249,451 +6.62% 23
Poland Poland 3,061,848 -3.96% 40
Portugal Portugal 2,794,454 -15.2% 44
Romania Romania 772,046 +22.2% 67
Russia Russia 3,914,304 -25.6% 36
Saudi Arabia Saudi Arabia 10,459,765 +5.91% 20
Senegal Senegal 738,000 -4.08% 68
Singapore Singapore 37,289,600 -0.75% 3
El Salvador El Salvador 242,307 -17.7% 82
Suriname Suriname 103,874 -5.22% 85
Slovenia Slovenia 1,017,798 +2.09% 62
Sweden Sweden 1,631,248 -0.241% 52
Togo Togo 1,952,879 -1.67% 48
Thailand Thailand 10,497,112 +0.579% 19
Trinidad & Tobago Trinidad & Tobago 498,544 +21.5% 73
Tunisia Tunisia 464,823 -1.03% 75
Turkey Turkey 12,366,172 -1.79% 15
Tanzania Tanzania 700,000 0% 69
Uruguay Uruguay 1,080,445 +10.5% 59
United States United States 62,214,119 +0.0847% 2
Vietnam Vietnam 20,518,926 +3.52% 7
South Africa South Africa 4,053,350 -8.2% 35

                    
# 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 = 'IS.SHP.GOOD.TU'

# 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 <- 'IS.SHP.GOOD.TU'

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