Employment to population ratio, 15+, male (%)

Source: worldbank.org, 19.12.2024

Year: 2023

Flag Country Value Value change, % Rank
United Arab Emirates United Arab Emirates 89.4 +1.46% 1
Argentina Argentina 68.2 +1.2% 35
Australia Australia 69 +0.548% 31
Austria Austria 63 -0.441% 60
Belgium Belgium 55.9 -0.278% 75
Burkina Faso Burkina Faso 51.7 -32.1% 81
Bulgaria Bulgaria 59.4 -1.44% 68
Bahamas Bahamas 88 +19.8% 2
Bosnia & Herzegovina Bosnia & Herzegovina 56.4 +2.21% 73
Belarus Belarus 71.7 -0.447% 20
Bolivia Bolivia 82.3 -0.245% 4
Brazil Brazil 68.3 +0.197% 34
Brunei Brunei 68.5 +0.347% 32
Bhutan Bhutan 70.7 +0.689% 24
Botswana Botswana 58.5 +6.73% 70
Canada Canada 65.8 +0.114% 44
Switzerland Switzerland 70.1 +0.739% 29
Chile Chile 65.2 +0.137% 50
Colombia Colombia 70.4 +1.05% 27
Costa Rica Costa Rica 64.8 -2.68% 52
Cyprus Cyprus 66 -1.17% 43
Czechia Czechia 67 +0.519% 39
Germany Germany 64.5 +0.365% 53
Denmark Denmark 64.4 -0.158% 55
Dominican Republic Dominican Republic 74.2 -0.247% 15
Ecuador Ecuador 75.1 +0.855% 13
Spain Spain 56.3 +1.04% 74
Estonia Estonia 67.2 +0.212% 38
Finland Finland 58.8 -1.47% 69
France France 55.7 -0.0539% 76
United Kingdom United Kingdom 63.7 -0.282% 56
Gambia Gambia 46.5 -26% 82
Greece Greece 54.9 +0.287% 77
Guatemala Guatemala 85.6 +5.64% 3
Hong Kong SAR China Hong Kong SAR China 61.4 -0.0521% 64
Honduras Honduras 72 +1.48% 19
Croatia Croatia 54.4 -0.525% 79
Hungary Hungary 65.6 +0.51% 47
Indonesia Indonesia 79.4 +1.17% 6
India India 73.2 +1.07% 17
Ireland Ireland 67.7 +0.964% 36
Iceland Iceland 76.2 +1.58% 9
Israel Israel 66.5 +0.868% 42
Italy Italy 54.8 +1.55% 78
Jamaica Jamaica 70.8 +2.79% 23
Japan Japan 69.5 +0.0504% 30
South Korea South Korea 71.5 -0.286% 21
Lithuania Lithuania 63.5 +0.204% 57
Luxembourg Luxembourg 62.9 +1.19% 61
Latvia Latvia 62.7 +0.54% 62
Moldova Moldova 70.3 -3.6% 28
Mexico Mexico 74.3 +0.547% 14
North Macedonia North Macedonia 52.7 -1.72% 80
Malta Malta 70.8 -5.5% 22
Mongolia Mongolia 64.8 -0.648% 51
Mauritius Mauritius 66.8 +2.67% 40
Netherlands Netherlands 70.6 +0.975% 25
Norway Norway 66.6 -0.409% 41
New Zealand New Zealand 74 +0.631% 16
Panama Panama 70.4 -1.47% 26
Peru Peru 77.2 -3% 8
Poland Poland 64.5 +0.289% 54
Portugal Portugal 60 +0.584% 67
Paraguay Paraguay 79 +1.63% 7
Romania Romania 58.2 -0.192% 71
Russia Russia 68.4 +1.09% 33
Rwanda Rwanda 62.6 +9.49% 63
Saudi Arabia Saudi Arabia 81.8 +5.54% 5
Singapore Singapore 72.5 -2.55% 18
El Salvador El Salvador 76 +0.574% 11
Serbia Serbia 60.3 +1.13% 66
Slovakia Slovakia 63.5 +0.313% 58
Slovenia Slovenia 60.9 -0.498% 65
Sweden Sweden 65.4 -0.127% 49
Seychelles Seychelles 63.2 -1.63% 59
Thailand Thailand 76.1 +1.03% 10
Tunisia Tunisia 56.6 +0.0991% 72
Turkey Turkey 65.7 +1.07% 45
Uruguay Uruguay 65.7 -1.19% 46
United States United States 65.5 +0.0947% 48
Vietnam Vietnam 75.3 -2.32% 12
South Africa South Africa 43 +4.01% 83
Zimbabwe Zimbabwe 67.5 +4.29% 37

                    
# 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.EMP.TOTL.SP.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.EMP.TOTL.SP.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))