Commercial service imports (current US$)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 8,234,605,089 -0.751% 64
Albania Albania 3,765,288,082 +9.54% 76
Argentina Argentina 22,389,228,211 +0.506% 43
Armenia Armenia 3,804,276,891 +14% 75
Antigua & Barbuda Antigua & Barbuda 556,625,705 +5.11% 100
Australia Australia 107,265,673,951 +7.35% 19
Austria Austria 87,771,909,918 +4.25% 23
Azerbaijan Azerbaijan 10,059,496,000 +18.2% 61
Belgium Belgium 158,903,891,769 -0.336% 13
Bangladesh Bangladesh 10,931,048,370 +1.93% 57
Bulgaria Bulgaria 8,195,170,000 +4.59% 65
Bahrain Bahrain 12,373,936,170 +2.58% 56
Bahamas Bahamas 2,200,681,164 +11.5% 86
Bosnia & Herzegovina Bosnia & Herzegovina 1,294,378,895 +15.8% 92
Belarus Belarus 6,481,623,115 +9.97% 67
Belize Belize 332,416,874 +17.5% 103
Brazil Brazil 101,356,219,622 +17.3% 20
Brunei Brunei 1,716,262,788 +6.47% 91
Bhutan Bhutan 220,693,128 -30% 107
Canada Canada 158,674,010,334 +5.14% 14
Switzerland Switzerland 214,434,138,636 +11.6% 9
Chile Chile 20,640,602,016 +0.937% 46
China China 609,936,333,483 +14.1% 2
Colombia Colombia 18,224,323,591 +8.08% 49
Cape Verde Cape Verde 280,786,679 +7.34% 105
Costa Rica Costa Rica 7,255,536,449 +14.3% 66
Cyprus Cyprus 21,915,214,314 +11% 44
Czechia Czechia 37,954,627,700 +6.8% 34
Germany Germany 549,751,651,762 +5.85% 3
Djibouti Djibouti 694,213,143 -7.91% 98
Dominica Dominica 156,768,691 +3.35% 111
Denmark Denmark 121,031,591,668 +7.15% 17
Dominican Republic Dominican Republic 6,156,500,000 +12% 70
Ecuador Ecuador 5,992,132,506 -1.3% 71
Spain Spain 111,558,518,699 +16.4% 18
Estonia Estonia 10,303,420,799 +4.97% 60
Finland Finland 46,687,293,373 +2.32% 32
France France 340,400,928,893 +2.7% 6
United Kingdom United Kingdom 398,926,373,685 +11% 4
Georgia Georgia 3,760,067,888 +5.72% 77
Gambia Gambia 160,904,229 +7.13% 110
Greece Greece 30,809,193,030 +5.48% 38
Grenada Grenada 424,380,947 +9.43% 101
Guatemala Guatemala 6,301,472,420 +14.4% 68
Hong Kong SAR China Hong Kong SAR China 90,279,136,204 +14.5% 22
Honduras Honduras 3,610,668,929 +2.1% 78
Croatia Croatia 8,297,070,066 +17.7% 63
Hungary Hungary 27,189,929,339 +1.75% 41
Indonesia Indonesia 57,432,000,333 +12.1% 29
India India 195,431,413,497 +10.2% 10
Iceland Iceland 4,978,773,363 +7.04% 74
Israel Israel 43,617,700,000 -6.36% 33
Italy Italy 161,485,111,975 +6.94% 11
Jamaica Jamaica 3,395,848,724 -0.2% 79
Japan Japan 243,363,950,040 +5.6% 8
Kazakhstan Kazakhstan 12,872,858,597 +5.85% 55
Cambodia Cambodia 3,038,667,313 +7.51% 81
St. Kitts & Nevis St. Kitts & Nevis 236,660,129 -18.9% 106
South Korea South Korea 161,441,300,000 +6.69% 12
Kuwait Kuwait 27,015,428,741 -3.02% 42
St. Lucia St. Lucia 597,609,900 +10.8% 99
Lesotho Lesotho 407,858,725 +0.287% 102
Lithuania Lithuania 14,573,097,266 +9.53% 53
Luxembourg Luxembourg 130,392,465,855 +2.68% 15
Latvia Latvia 5,890,292,808 +2.74% 72
Moldova Moldova 1,741,520,000 +15.3% 90
Maldives Maldives 1,869,380,242 +11.2% 89
Mexico Mexico 70,158,470,103 -6.08% 27
North Macedonia North Macedonia 1,972,054,571 -3.34% 88
Malta Malta 17,178,678,497 +9.86% 51
Montenegro Montenegro 1,174,135,088 +2.33% 95
Mozambique Mozambique 2,042,086,286 +4.57% 87
Malaysia Malaysia 56,149,019,149 +8.04% 30
Namibia Namibia 2,395,331,496 +9.12% 85
Nigeria Nigeria 17,291,350,788 +0.227% 50
Nicaragua Nicaragua 1,279,000,000 +15.9% 93
Netherlands Netherlands 267,773,237,151 +5.84% 7
Norway Norway 64,120,137,433 +6.97% 28
Nepal Nepal 2,781,089,285 +36.8% 82
New Zealand New Zealand 19,320,700,170 +5.61% 48
Pakistan Pakistan 10,541,574,086 +12.6% 58
Panama Panama 5,649,890,538 -2.8% 73
Peru Peru 14,863,962,407 +9.12% 52
Philippines Philippines 37,021,799,002 +24.3% 35
Poland Poland 75,043,000,000 +13.7% 25
Portugal Portugal 27,637,206,771 +6.95% 40
Paraguay Paraguay 2,522,036,755 +1.52% 84
Palestinian Territories Palestinian Territories 1,231,266,408 -33.1% 94
Qatar Qatar 32,090,934,066 -15% 37
Romania Romania 30,524,525,800 +7.31% 39
Russia Russia 80,167,620,000 +6.04% 24
Saudi Arabia Saudi Arabia 93,652,543,273 +5.97% 21
Singapore Singapore 350,835,283,259 +7.61% 5
Solomon Islands Solomon Islands 219,269,515 -3.39% 108
El Salvador El Salvador 3,202,942,676 +22.7% 80
Suriname Suriname 919,333,748 +45.9% 97
Slovakia Slovakia 13,061,923,693 +5.85% 54
Slovenia Slovenia 9,479,493,300 +7.07% 62
Sweden Sweden 124,691,209,652 +9.36% 16
Thailand Thailand 73,330,899,098 +12.2% 26
Tajikistan Tajikistan 964,123,779 +30% 96
Timor-Leste Timor-Leste 331,302,793 -14.5% 104
Tonga Tonga 152,317,479 +7.77% 112
Trinidad & Tobago Trinidad & Tobago 2,613,177,885 +2.13% 83
Turkey Turkey 52,004,000,000 +8.06% 31
Ukraine Ukraine 21,547,000,000 -7.04% 45
Uruguay Uruguay 6,161,013,934 -3.2% 69
United States United States 786,596,000,000 +8.84% 1
Uzbekistan Uzbekistan 10,428,155,997 +28.1% 59
St. Vincent & Grenadines St. Vincent & Grenadines 193,752,662 +5.21% 109
Vietnam Vietnam 36,183,000,000 +24.4% 36
Samoa Samoa 119,754,141 -3.17% 113
South Africa South Africa 19,523,988,884 +6.66% 47

                    
# 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.SERV.CD.WT'

# 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.SERV.CD.WT'

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