Taxes on goods and services (% value added of industry and services)

Source: worldbank.org, 19.12.2024

Year: 2021

Flag Country Value Value change, % Rank
Albania Albania 19.9 +9.31% 5
United Arab Emirates United Arab Emirates 0.54 -21.5% 117
Argentina Argentina 7.38 +3.19% 87
Armenia Armenia 15.6 +7.36% 20
Australia Australia 5.75 +6.06% 99
Austria Austria 13.3 +2.44% 35
Azerbaijan Azerbaijan 8.36 -16.6% 79
Burundi Burundi 17.9 +1.45% 10
Belgium Belgium 11.5 +5.86% 52
Burkina Faso Burkina Faso 11.1 +19.9% 57
Bangladesh Bangladesh 4.91 +10.8% 103
Bulgaria Bulgaria 17.2 -1.07% 13
Bahamas Bahamas 11.2 -24.5% 54
Bosnia & Herzegovina Bosnia & Herzegovina 20.3 +2.73% 3
Belarus Belarus 10.9 +0.0154% 59
Brazil Brazil 6.82 +13.3% 90
Botswana Botswana 5.96 +14.9% 96
Central African Republic Central African Republic 6.74 -18.2% 91
Switzerland Switzerland 5.31 -1.31% 101
Chile Chile 13.1 +15.3% 37
China China 5.03 -4.19% 102
Côte d’Ivoire Côte d’Ivoire 7.01 +3.19% 89
Cameroon Cameroon 8.14 +8.2% 81
Congo - Kinshasa Congo - Kinshasa 4.67 +16.2% 105
Congo - Brazzaville Congo - Brazzaville 3.31 -16.7% 111
Colombia Colombia 8.76 +7.56% 73
Costa Rica Costa Rica 8.53 +13% 76
Cyprus Cyprus 13.5 +2.02% 32
Czechia Czechia 9.37 -3.58% 69
Germany Germany 6.68 +9.56% 92
Denmark Denmark 15.3 -6.05% 22
Dominican Republic Dominican Republic 9.55 +14.9% 64
Ecuador Ecuador 7.68 +1.53% 85
Spain Spain 9.52 +6.53% 66
Estonia Estonia 15.3 +1.99% 23
Ethiopia Ethiopia 3.52 -22% 110
Finland Finland 17 -0.796% 14
Fiji Fiji 11.1 -16.3% 58
France France 10.4 -9.4% 62
Gabon Gabon 2.3 +7.92% 114
United Kingdom United Kingdom 12.9 +3.2% 40
Georgia Georgia 16.6 +6.09% 15
Ghana Ghana 7.27 +20.2% 88
Equatorial Guinea Equatorial Guinea 0.946 -38.6% 116
Greece Greece 18.6 +3.6% 8
Guatemala Guatemala 7.93 +14.3% 82
Croatia Croatia 23.5 +3.04% 1
Hungary Hungary 18.3 -2.38% 9
Indonesia Indonesia 5.33 +8.45% 100
Ireland Ireland 6.54 +3.23% 93
Iceland Iceland 13.2 +0.996% 36
Israel Israel 12.5 +7.18% 43
Italy Italy 11.2 +5.93% 55
Kazakhstan Kazakhstan 3.93 -7.9% 108
Kenya Kenya 8.74 -0.814% 74
Kyrgyzstan Kyrgyzstan 13.7 +32.1% 30
Cambodia Cambodia 8.65 -13.9% 75
Kiribati Kiribati 16.3 -2.98% 16
South Korea South Korea 6.34 +2.71% 95
Laos Laos 10 +8.27% 63
Lebanon Lebanon 2.54 -14.9% 113
Sri Lanka Sri Lanka 4.25 +0.296% 106
Lesotho Lesotho 18.7 -8.61% 7
Lithuania Lithuania 13.5 +3.01% 31
Luxembourg Luxembourg 12.4 +4.67% 46
Latvia Latvia 23.5 -1.27% 2
Macao SAR China Macao SAR China 15.6 -8.91% 19
Morocco Morocco 14.1 +6.78% 26
Moldova Moldova 18.9 +6.19% 6
Madagascar Madagascar 8.5 +10.2% 77
Maldives Maldives 13.7 +31.2% 29
Mexico Mexico 6.41 -4.83% 94
North Macedonia North Macedonia 15 +10.9% 24
Malta Malta 10.7 -4.01% 60
Mongolia Mongolia 12.5 +17.5% 44
Mozambique Mozambique 16 +22.6% 17
Mauritius Mauritius 14 -14.4% 27
Malawi Malawi 7.68 -1.56% 84
Malaysia Malaysia 3.27 -5.04% 112
Namibia Namibia 8.98 +27.7% 71
Nicaragua Nicaragua 13.5 +12.1% 33
Netherlands Netherlands 12.4 +0.0739% 47
Norway Norway 12.1 -16% 48
Nepal Nepal 12.8 +22.1% 41
New Zealand New Zealand 11.6 +6.44% 51
Panama Panama 3.95 -3.62% 107
Peru Peru 9.12 +19.8% 70
Philippines Philippines 4.88 +1.44% 104
Papua New Guinea Papua New Guinea 5.83 +9.93% 98
Poland Poland 15.7 +8.72% 18
Portugal Portugal 14.6 +3.98% 25
Paraguay Paraguay 7.57 +2.72% 86
Palestinian Territories Palestinian Territories 13.3 -5.78% 34
Romania Romania 11.8 +4.73% 49
Russia Russia 9.54 -1.33% 65
Saudi Arabia Saudi Arabia 8.4 +31.4% 78
Senegal Senegal 12.4 -2.48% 45
Singapore Singapore 3.78 -2.14% 109
El Salvador El Salvador 13.1 +10.5% 38
San Marino San Marino 8.77 +11.5% 72
Serbia Serbia 17.7 -12.2% 11
Slovakia Slovakia 13 -0.45% 39
Slovenia Slovenia 15.4 +3.66% 21
Sweden Sweden 14 -1.52% 28
Eswatini Eswatini 7.75 -1.6% 83
Togo Togo 11.2 +5.99% 56
Thailand Thailand 9.5 -0.492% 67
Tajikistan Tajikistan 11.7 +7.62% 50
Timor-Leste Timor-Leste 2.18 -35.9% 115
Turkey Turkey 12.6 -6.48% 42
Tanzania Tanzania 8.26 +0.641% 80
Uganda Uganda 9.43 +10.2% 68
Ukraine Ukraine 17.5 +2.59% 12
United States United States 0.402 -6.59% 118
Uzbekistan Uzbekistan 10.4 -6.75% 61
Samoa Samoa 20.2 -1.74% 4
South Africa South Africa 11.3 +7.46% 53
Zambia Zambia 5.95 -9.88% 97

                    
# 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 = 'GC.TAX.GSRV.VA.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 <- 'GC.TAX.GSRV.VA.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))