Fuel exports (% of merchandise exports)

Source: worldbank.org, 01.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Albania Albania 3.26 -48.7% 50
Argentina Argentina 8.76 -0.627% 25
Armenia Armenia 0.669 -26.3% 72
Antigua & Barbuda Antigua & Barbuda 0 84
Australia Australia 33.2 -5.13% 5
Azerbaijan Azerbaijan 88 -3.85% 2
Belgium Belgium 11.6 -11.7% 21
Burkina Faso Burkina Faso 0.0208 +29.5% 80
Bulgaria Bulgaria 7.76 -1.6% 28
Bosnia & Herzegovina Bosnia & Herzegovina 6.49 -31.8% 36
Belize Belize 0.00484 -97.2% 81
Bolivia Bolivia 18.9 -4.03% 12
Brazil Brazil 17 +4.42% 15
Barbados Barbados 8.01 -6.98% 26
Canada Canada 27.6 +1.26% 8
Switzerland Switzerland 1.21 -17.4% 69
Chile Chile 1.32 -26.9% 65
China China 1.5 -17.1% 63
Cyprus Cyprus 49.1 +0.137% 4
Czechia Czechia 1.65 -14% 62
Germany Germany 2.06 -1.21% 58
Denmark Denmark 3.73 +1.66% 45
Dominican Republic Dominican Republic 0.435 +42.5% 74
Ecuador Ecuador 27.5 -4.78% 9
Egypt Egypt 12.5 -29% 19
Spain Spain 5.8 -14.9% 38
Estonia Estonia 7.77 -7.55% 27
Finland Finland 7.52 -20.8% 30
Fiji Fiji 0.0388 +27.5% 79
United Kingdom United Kingdom 7.35 -18% 31
Georgia Georgia 2.33 -44.6% 57
Greece Greece 30.2 -6.53% 7
Grenada Grenada 0.000281 -95.3% 83
Guatemala Guatemala 2.88 +50.1% 54
Guyana Guyana 91.9 +6.7% 1
Hong Kong SAR China Hong Kong SAR China 0.112 -16.5% 77
Croatia Croatia 13.1 +9.16% 18
Hungary Hungary 3.32 +5.58% 49
India India 17.1 -17.4% 14
Ireland Ireland 0.353 -27.2% 75
Iceland Iceland 1.95 -20.2% 60
Israel Israel 1.23 -76.9% 68
Italy Italy 2.98 -17.8% 52
Japan Japan 1.39 -21.3% 64
Kyrgyzstan Kyrgyzstan 7.32 +21% 32
South Korea South Korea 7.7 -9.95% 29
Sri Lanka Sri Lanka 3.44 +6.64% 47
Lithuania Lithuania 14 -1.83% 17
Luxembourg Luxembourg 0.123 -10.7% 76
Latvia Latvia 6.97 -3.16% 35
Moldova Moldova 2.38 +45.5% 56
Maldives Maldives 0.102 -35.8% 78
Mexico Mexico 4.42 -19.3% 43
North Macedonia North Macedonia 3.46 -15.9% 46
Malta Malta 10.1 +87.5% 23
Myanmar (Burma) Myanmar (Burma) 22 -9.36% 11
Montenegro Montenegro 25.3 -31% 10
Mauritius Mauritius 0.000628 -67.7% 82
Malaysia Malaysia 14.4 -12.8% 16
Namibia Namibia 1.28 -25.3% 66
Netherlands Netherlands 12.4 -13.2% 20
Norway Norway 66.1 -3.24% 3
New Zealand New Zealand 1.11 -19% 70
Pakistan Pakistan 1.72 +195% 61
Panama Panama 1.01 +236% 71
Philippines Philippines 1.26 +10.4% 67
Poland Poland 2.58 -15.4% 55
Portugal Portugal 6.98 +5.56% 34
Paraguay Paraguay 10.6 -19.8% 22
Romania Romania 4.88 -8.13% 41
El Salvador El Salvador 5 -5.58% 40
Suriname Suriname 3.14 +18,460% 51
Slovakia Slovakia 4.07 +16.5% 44
Slovenia Slovenia 4.62 -17% 42
Sweden Sweden 7.12 -4.75% 33
Togo Togo 1.96 +0.762% 59
Thailand Thailand 3.42 -11.5% 48
Trinidad & Tobago Trinidad & Tobago 31.3 +3.05% 6
Turkey Turkey 6.16 -3.14% 37
Ukraine Ukraine 0.501 -53.7% 73
United States United States 18.3 -1.96% 13
Uzbekistan Uzbekistan 5.31 +19.1% 39
South Africa South Africa 9.61 -10.4% 24
Zimbabwe Zimbabwe 2.91 +2.63% 53

                    
# 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 = 'TX.VAL.FUEL.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 <- 'TX.VAL.FUEL.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))