Unemployment, male (% of male labor force)

Source: worldbank.org, 19.12.2024

Year: 2023

Flag Country Value Value change, % Rank
United Arab Emirates United Arab Emirates 1.5 +2.96% 81
Argentina Argentina 5.63 -8.14% 32
Australia Australia 3.76 -0.635% 54
Austria Austria 5.48 +6.04% 35
Belgium Belgium 5.95 +1.74% 28
Burkina Faso Burkina Faso 4.98 +161% 38
Bulgaria Bulgaria 4.41 -0.966% 43
Bahamas Bahamas 9.06 +0.544% 9
Bosnia & Herzegovina Bosnia & Herzegovina 9.13 -14.7% 8
Belarus Belarus 4.14 -2.48% 49
Bolivia Bolivia 2.66 -11.6% 72
Brazil Brazil 6.6 -11.6% 24
Brunei Brunei 5.28 +12.4% 37
Bhutan Bhutan 2.36 -46.2% 74
Botswana Botswana 20 -6.4% 2
Canada Canada 5.56 +2.74% 34
Switzerland Switzerland 3.83 -1.62% 52
Chile Chile 8.75 +11.7% 10
Colombia Colombia 7.95 -7.8% 12
Costa Rica Costa Rica 7.12 -17.7% 22
Cyprus Cyprus 6.03 +1.23% 27
Czechia Czechia 2.21 +23.5% 76
Germany Germany 3.27 -3.85% 64
Denmark Denmark 4.93 +12.6% 40
Dominican Republic Dominican Republic 3.47 +5.09% 60
Ecuador Ecuador 2.9 -11.1% 67
Spain Spain 10.7 -5.36% 5
Estonia Estonia 6.12 +0.907% 26
Finland Finland 7.85 +11.3% 14
France France 7.46 -0.161% 18
United Kingdom United Kingdom 4.34 +10.9% 45
Gambia Gambia 7.18 +43% 21
Greece Greece 8.43 -9.15% 11
Guatemala Guatemala 1.94 -10% 79
Hong Kong SAR China Hong Kong SAR China 3.49 -31.8% 59
Honduras Honduras 4.49 -24.4% 42
Croatia Croatia 5.61 -8.59% 33
Hungary Hungary 4.07 +9.41% 50
Indonesia Indonesia 3.45 -5.6% 61
India India 4.22 -14% 47
Ireland Ireland 4.36 +0.138% 44
Iceland Iceland 3.87 -6.48% 51
Israel Israel 3.54 -7.02% 57
Italy Italy 6.78 -4.7% 23
Jamaica Jamaica 2.24 -29.8% 75
Japan Japan 2.8 0% 68
South Korea South Korea 2.64 -3.09% 73
Lithuania Lithuania 7.3 +13.4% 20
Luxembourg Luxembourg 4.97 +11.5% 39
Latvia Latvia 7.58 -6.56% 17
Moldova Moldova 1.96 +71.9% 78
Mexico Mexico 2.74 -14.9% 69
North Macedonia North Macedonia 14.4 -8.99% 3
Malta Malta 3.23 +2.74% 65
Mongolia Mongolia 5.86 -14.3% 30
Mauritius Mauritius 4.23 -13.7% 46
Netherlands Netherlands 3.35 +2.54% 63
Norway Norway 3.68 +9.03% 55
New Zealand New Zealand 3.52 +14.1% 58
Panama Panama 5.3 -26.7% 36
Peru Peru 4.15 +18.7% 48
Poland Poland 2.7 -2.66% 71
Portugal Portugal 6.14 +10.8% 25
Paraguay Paraguay 4.66 -17.7% 41
Romania Romania 5.94 -1.51% 29
Russia Russia 2.97 -21.4% 66
Rwanda Rwanda 10.5 -23.3% 6
Saudi Arabia Saudi Arabia 2.08 -21% 77
Singapore Singapore 3.23 -4.98% 65
El Salvador El Salvador 2.71 -2.48% 70
Serbia Serbia 7.94 -1.56% 13
Slovakia Slovakia 5.76 -2.88% 31
Slovenia Slovenia 3.6 -4.05% 56
Sweden Sweden 7.38 +6.49% 19
Seychelles Seychelles 3.45 -32.2% 62
Thailand Thailand 0.669 -20.4% 82
Tunisia Tunisia 12.8 -2.77% 4
Turkey Turkey 7.68 -14.3% 16
Uruguay Uruguay 7.7 +11.9% 15
United States United States 3.8 +3.23% 53
Vietnam Vietnam 1.77 +9.66% 80
South Africa South Africa 30 -4.78% 1
Zimbabwe Zimbabwe 9.19 -4.52% 7

                    
# 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 = 'SL.UEM.TOTL.MA.NE.ZS'

# 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 <- 'SL.UEM.TOTL.MA.NE.ZS'

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