Imports of goods and services (constant 2015 US$)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 13,136,220,129 -6.15% 83
Albania Albania 7,520,300,077 +5.99% 101
Argentina Argentina 70,000,992,785 -10.6% 45
Armenia Armenia 13,245,276,190 +31.4% 82
Australia Australia 386,345,243,468 +6.43% 16
Austria Austria 221,884,035,861 -5.04% 25
Belgium Belgium 420,278,333,635 -3.53% 15
Benin Benin 4,574,672,675 -0.752% 112
Burkina Faso Burkina Faso 7,823,659,192 +15.8% 98
Bangladesh Bangladesh 67,776,851,245 -4.6% 48
Bulgaria Bulgaria 46,947,524,741 +1.31% 50
Bahamas Bahamas 4,883,159,215 +12.7% 110
Bosnia & Herzegovina Bosnia & Herzegovina 11,928,290,460 +2.79% 87
Belarus Belarus 41,856,038,371 +5.25% 54
Bermuda Bermuda 1,662,891,305 +6.14% 122
Brazil Brazil 311,714,709,219 +14.7% 18
Brunei Brunei 8,229,478,836 +0.168% 97
Botswana Botswana 7,124,787,802 +12.3% 103
Central African Republic Central African Republic 841,392,298 +29.8% 124
Canada Canada 617,043,622,632 +0.635% 8
Switzerland Switzerland 438,178,419,023 +0.387% 14
Chile Chile 88,180,247,422 +2.46% 42
Côte d’Ivoire Côte d’Ivoire 22,359,001,189 +4% 70
Cameroon Cameroon 9,756,627,095 +1.94% 93
Congo - Kinshasa Congo - Kinshasa 80,987,324,804 +18.4% 44
Congo - Brazzaville Congo - Brazzaville 4,383,777,831 +5% 114
Colombia Colombia 87,005,469,061 +4.22% 43
Comoros Comoros 417,947,707 +2.75% 128
Cape Verde Cape Verde 1,412,064,794 +2.73% 123
Costa Rica Costa Rica 24,979,707,419 +5.99% 65
Cyprus Cyprus 31,351,970,988 +2.36% 58
Czechia Czechia 179,430,593,752 +0.932% 27
Germany Germany 1,507,303,234,430 +0.19% 2
Djibouti Djibouti 5,947,109,039 +12.5% 108
Denmark Denmark 206,828,965,551 +2.98% 26
Dominican Republic Dominican Republic 31,346,122,628 +3.36% 59
Ecuador Ecuador 28,223,444,957 +1.66% 62
Egypt Egypt 112,047,485,756 +4.66% 35
Spain Spain 454,644,500,199 +2.43% 13
Estonia Estonia 24,842,152,352 +0.0325% 66
Ethiopia Ethiopia 23,719,790,256 +26% 68
Finland Finland 100,617,285,901 -2.45% 39
France France 907,635,740,217 -1.22% 4
Gabon Gabon 8,867,260,856 +6.84% 95
United Kingdom United Kingdom 995,888,922,797 +2.69% 3
Georgia Georgia 13,787,552,973 +8.49% 81
Ghana Ghana 28,947,938,504 +9.52% 60
Guinea Guinea 13,067,571,987 +23% 84
Gambia Gambia 701,828,084 +7.2% 125
Guinea-Bissau Guinea-Bissau 496,523,529 +1.84% 127
Equatorial Guinea Equatorial Guinea 2,973,650,499 +0.176% 120
Greece Greece 100,729,367,699 +5.48% 38
Guatemala Guatemala 28,689,546,178 +8.97% 61
Hong Kong SAR China Hong Kong SAR China 579,941,696,923 +3.55% 11
Honduras Honduras 15,679,513,724 +2.33% 78
Croatia Croatia 39,629,329,219 +5.35% 56
Haiti Haiti 4,614,578,439 -16.2% 111
Hungary Hungary 137,559,040,849 -3.95% 31
Indonesia Indonesia 246,879,836,126 +7.95% 24
India India 803,920,796,827 -1.13% 5
Ireland Ireland 547,557,831,115 +6.49% 12
Iran Iran 45,570,367,791 -1.05% 53
Iraq Iraq 98,055,390,315 +23.9% 40
Iceland Iceland 10,440,169,917 +2.75% 90
Israel Israel 121,532,038,958 -0.434% 33
Italy Italy 607,973,640,024 -0.722% 9
Kenya Kenya 21,836,650,645 +2.5% 72
Cambodia Cambodia 25,420,406,397 +7.53% 63
Kiribati Kiribati 266,072,875 -1.76% 129
Libya Libya 14,348,349,276 -3.02% 80
Sri Lanka Sri Lanka 23,272,889,563 +22.5% 69
Lithuania Lithuania 46,819,141,136 +2.4% 51
Luxembourg Luxembourg 131,112,859,839 -0.279% 32
Latvia Latvia 24,697,238,975 -2.34% 67
Macao SAR China Macao SAR China 21,295,043,876 -3.89% 73
Morocco Morocco 68,423,569,863 +13% 47
Moldova Moldova 7,540,362,416 +5.23% 100
Madagascar Madagascar 6,003,082,307 +0.868% 107
Mexico Mexico 586,265,476,344 +2.68% 10
North Macedonia North Macedonia 10,142,927,232 -0.619% 92
Mali Mali 7,798,677,593 -3.5% 99
Malta Malta 22,147,200,992 +4.65% 71
Montenegro Montenegro 4,246,766,835 +5.55% 115
Mongolia Mongolia 17,300,662,643 +17.7% 75
Mozambique Mozambique 11,389,092,214 -1.5% 88
Mauritius Mauritius 6,816,663,123 +8.91% 104
Malaysia Malaysia 269,712,973,314 +8.95% 21
Namibia Namibia 10,577,003,476 +7.94% 89
Niger Niger 3,302,132,516 -2% 117
Nicaragua Nicaragua 10,274,828,123 +12% 91
Netherlands Netherlands 717,156,766,984 +0.263% 6
Norway Norway 145,487,444,463 +3.66% 29
Nepal Nepal 12,817,438,654 -2.54% 85
Pakistan Pakistan 112,018,873,042 +4.11% 36
Peru Peru 60,420,019,948 +8.02% 49
Philippines Philippines 166,827,420,688 +4.18% 28
Poland Poland 353,787,239,687 +4.24% 17
Portugal Portugal 117,517,999,020 +4.95% 34
Paraguay Paraguay 18,058,854,644 +4.16% 74
Palestinian Territories Palestinian Territories 6,555,800,000 -31.1% 105
Romania Romania 140,681,313,042 +3.84% 30
Rwanda Rwanda 5,885,554,511 +11.5% 109
Saudi Arabia Saudi Arabia 252,065,905,800 +3.31% 23
Sudan Sudan 8,468,939,956 -21.5% 96
Senegal Senegal 12,268,086,293 -5.08% 86
Singapore Singapore 692,138,999,509 +6.65% 7
Sierra Leone Sierra Leone 3,252,066,360 +12% 118
El Salvador El Salvador 14,365,691,168 +7.98% 79
Somalia Somalia 7,494,371,359 +11.4% 102
Serbia Serbia 41,460,549,689 +8.31% 55
Slovakia Slovakia 93,488,516,777 +2.28% 41
Slovenia Slovenia 45,584,948,098 +3.91% 52
Sweden Sweden 277,755,588,771 +1.67% 20
Seychelles Seychelles 2,088,633,776 +7.5% 121
Chad Chad 3,330,447,851 +2.97% 116
Togo Togo 3,134,336,231 +5.4% 119
Thailand Thailand 269,618,330,183 +6.29% 22
Tunisia Tunisia 25,404,147,665 +4.57% 64
Turkey Turkey 294,451,329,028 -4.11% 19
Tanzania Tanzania 16,056,223,449 +9.22% 77
Uganda Uganda 9,679,680,808 +4.71% 94
Ukraine Ukraine 69,851,176,336 +7.69% 46
Uruguay Uruguay 16,984,395,001 -1.47% 76
United States United States 3,686,732,932,632 +5.31% 1
Uzbekistan Uzbekistan 35,956,787,053 -1.5% 57
Samoa Samoa 540,487,766 -3% 126
Kosovo Kosovo 6,341,627,362 +8.88% 106
South Africa South Africa 103,050,370,578 -6.33% 37
Zimbabwe Zimbabwe 4,399,008,093 +2.03% 113

                    
# 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.IMP.GNFS.KD'

# 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.IMP.GNFS.KD'

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