Energy intensity level of primary energy (MJ/$2017 PPP GDP)

Source: worldbank.org, 01.09.2025

Year: 2022

Flag Country Value Value change, % Rank
Aruba Aruba 2.9 -7.35% 70
Albania Albania 2.06 -9.25% 93
Andorra Andorra 1.81 -4.23% 98
Argentina Argentina 3.29 -2.95% 56
Antigua & Barbuda Antigua & Barbuda 4.48 -7.25% 35
Australia Australia 4.12 +0.488% 41
Austria Austria 2.55 -10.8% 80
Azerbaijan Azerbaijan 4.4 -6.98% 36
Burundi Burundi 7.4 -1.07% 11
Belgium Belgium 3.4 -11.9% 54
Burkina Faso Burkina Faso 5.4 -0.552% 24
Bulgaria Bulgaria 4.72 0% 32
Bahamas Bahamas 2.42 -15.7% 84
Bosnia & Herzegovina Bosnia & Herzegovina 5.53 -6.11% 23
Belize Belize 4.29 -10.3% 38
Bermuda Bermuda 1.51 -0.658% 100
Brazil Brazil 3.87 -2.27% 45
Barbados Barbados 3.76 -6.23% 47
Bhutan Bhutan 9.04 -7% 7
Central African Republic Central African Republic 8.31 -1.19% 10
Canada Canada 6.44 -1.68% 19
Switzerland Switzerland 1.48 -3.27% 101
Chile Chile 3.19 -7.8% 60
Colombia Colombia 2.18 -6.44% 89
Comoros Comoros 4.3 +0.703% 37
Cape Verde Cape Verde 2.17 -11.4% 90
Costa Rica Costa Rica 1.91 -4.02% 96
Cyprus Cyprus 2.36 -3.67% 85
Czechia Czechia 3.98 -4.33% 43
Germany Germany 2.47 -8.52% 82
Djibouti Djibouti 2.03 -2.4% 95
Dominica Dominica 2.95 -2.64% 68
Denmark Denmark 1.83 -6.63% 97
Spain Spain 2.53 -4.89% 81
Estonia Estonia 4.12 +10.5% 41
Finland Finland 4.82 -6.41% 31
Fiji Fiji 2.15 -5.29% 91
France France 2.83 -12.4% 72
Micronesia (Federated States of) Micronesia (Federated States of) 6.62 +2.48% 16
United Kingdom United Kingdom 2.04 -7.27% 94
Georgia Georgia 3.64 -5.7% 50
Guinea Guinea 4.95 -3.51% 30
Gambia Gambia 3.16 +1.61% 61
Guinea-Bissau Guinea-Bissau 6.95 -2.66% 13
Equatorial Guinea Equatorial Guinea 5.9 +13.9% 22
Greece Greece 2.58 -4.8% 79
Grenada Grenada 2.67 -3.96% 76
Guyana Guyana 2.06 -26.4% 93
Croatia Croatia 2.75 -5.5% 74
Hungary Hungary 3.12 -10.3% 64
Ireland Ireland 0.97 -11% 104
Iceland Iceland 11.9 -3.24% 4
Israel Israel 2.3 -3.77% 87
Italy Italy 2.3 -8.37% 87
Japan Japan 3.15 -3.08% 62
Kyrgyzstan Kyrgyzstan 4.69 -8.93% 33
Kiribati Kiribati 6.82 -0.438% 14
St. Kitts & Nevis St. Kitts & Nevis 2.63 0% 77
South Korea South Korea 5.11 -3.95% 27
Laos Laos 4.51 +6.12% 34
Liberia Liberia 13.8 -1.78% 2
St. Lucia St. Lucia 2.94 -12.2% 69
Lesotho Lesotho 9.02 -13.4% 8
Lithuania Lithuania 2.59 -11.9% 78
Luxembourg Luxembourg 1.71 -13.6% 99
Latvia Latvia 2.88 -7.1% 71
Macao SAR China Macao SAR China 1.13 +32.9% 103
Morocco Morocco 3.05 -2.87% 66
Moldova Moldova 4.69 -4.67% 33
Madagascar Madagascar 9 -3.74% 9
Maldives Maldives 2.79 -2.79% 73
Mexico Mexico 3 +0.334% 67
Marshall Islands Marshall Islands 11 +6.2% 5
North Macedonia North Macedonia 3.22 -0.923% 58
Mali Mali 6.26 -2.64% 20
Malta Malta 1.18 -2.48% 102
Montenegro Montenegro 3.43 -2.83% 53
Mauritania Mauritania 3.74 +5.65% 48
Malawi Malawi 3.33 +9.54% 55
New Caledonia New Caledonia 13.5 +9.07% 3
Netherlands Netherlands 2.53 -14.2% 81
Norway Norway 3.21 -6.41% 59
Nauru Nauru 6.79 -2.16% 15
New Zealand New Zealand 3.52 -6.63% 51
Palau Palau 13.8 +3.99% 1
Papua New Guinea Papua New Guinea 6.47 -1.07% 18
Poland Poland 3.13 -8.48% 63
Puerto Rico Puerto Rico 0.5 -26.5% 105
Portugal Portugal 2.31 -4.55% 86
Palestinian Territories Palestinian Territories 3.1 -0.958% 65
French Polynesia French Polynesia 2.58 -0.769% 79
Romania Romania 2.12 -11.7% 92
Rwanda Rwanda 3.51 -2.23% 52
Solomon Islands Solomon Islands 5.18 +2.17% 26
Sierra Leone Sierra Leone 5.29 -3.64% 25
Somalia Somalia 6.51 -0.913% 17
Serbia Serbia 5.02 +1.01% 29
São Tomé & Príncipe São Tomé & Príncipe 3.64 -8.31% 50
Slovakia Slovakia 3.83 -7.49% 46
Slovenia Slovenia 3.15 -3.37% 62
Sweden Sweden 3.24 -7.16% 57
Eswatini Eswatini 3.89 -0.512% 44
Sint Maarten Sint Maarten 7.12 -7.53% 12
Seychelles Seychelles 2.69 -5.61% 75
Turks & Caicos Islands Turks & Caicos Islands 5.95 0% 21
Chad Chad 4.2 -3.23% 39
Timor-Leste Timor-Leste 2.42 -1.22% 84
Tonga Tonga 4.03 -13.3% 42
Tunisia Tunisia 3.7 -2.89% 49
Turkey Turkey 2.27 -8.47% 88
Tuvalu Tuvalu 2.79 0% 73
Uganda Uganda 9.86 -3.33% 6
United States United States 4.17 -1.65% 40
St. Vincent & Grenadines St. Vincent & Grenadines 2.43 -1.22% 83
Vanuatu Vanuatu 5.04 -2.51% 28
Samoa Samoa 5.4 +10.2% 24

                    
# 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 = 'EG.EGY.PRIM.PP.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 <- 'EG.EGY.PRIM.PP.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))