Hospital beds (per 1,000 people)

Source: worldbank.org, 01.09.2025

Year: 2020

Flag Country Value Value change, % Rank
Afghanistan Afghanistan 0.34 -10.5% 107
Albania Albania 2.91 +2.11% 52
United Arab Emirates United Arab Emirates 1.94 +3.74% 74
Argentina Argentina 3.2 -13.7% 45
Armenia Armenia 4.59 +9.81% 27
Antigua & Barbuda Antigua & Barbuda 3.29 +1.54% 44
Austria Austria 7.06 -1.81% 7
Belgium Belgium 5.52 -0.719% 19
Benin Benin 0.47 +11.9% 105
Burkina Faso Burkina Faso 0.2 -50% 110
Bulgaria Bulgaria 7.77 +1.44% 5
Bahamas Bahamas 2.69 -0.37% 57
Bolivia Bolivia 1.36 +7.94% 85
Brazil Brazil 2.43 +8.48% 63
Barbados Barbados 5.66 -1.39% 16
Brunei Brunei 3.88 +4.86% 39
Bhutan Bhutan 2.12 +1.92% 70
Botswana Botswana 2.26 -1.74% 67
Canada Canada 2.56 +1.19% 60
Switzerland Switzerland 4.48 -2.4% 28
Chile Chile 2.03 -0.49% 72
China China 5 +3.52% 24
Colombia Colombia 1.69 -2.87% 78
Costa Rica Costa Rica 1.15 +5.5% 90
Cuba Cuba 4.19 +0.48% 35
Czechia Czechia 6.6 -0.901% 10
Germany Germany 7.8 -1.39% 4
Dominica Dominica 3 -0.662% 49
Denmark Denmark 2.59 -0.385% 59
Dominican Republic Dominican Republic 1.42 +13.6% 81
Ecuador Ecuador 1.32 -5.04% 86
Egypt Egypt 1.13 -7.38% 91
Eritrea Eritrea 1 -0.99% 96
Spain Spain 2.95 0% 51
Estonia Estonia 4.46 -1.55% 29
Finland Finland 2.83 -15.5% 54
France France 6 -1.64% 13
United Kingdom United Kingdom 2.43 -0.816% 63
Georgia Georgia 4.94 +6.47% 25
Gambia Gambia 1.11 +18.1% 92
Guatemala Guatemala 0.43 -8.51% 106
Guyana Guyana 2.25 +3.21% 68
Honduras Honduras 0.71 +9.23% 101
Croatia Croatia 5.6 +0.358% 17
Haiti Haiti 5.03 +3.29% 23
Hungary Hungary 6.76 -2.17% 8
Indonesia Indonesia 1.4 +18.6% 82
India India 1.62 -0.613% 80
Ireland Ireland 2.91 +0.345% 52
Iraq Iraq 1.2 0% 88
Iceland Iceland 2.83 +1.07% 54
Israel Israel 3.07 -1.6% 48
Italy Italy 3.18 +0.633% 47
Jamaica Jamaica 1.71 -1.16% 77
Jordan Jordan 1.37 +0.735% 84
Japan Japan 12.7 -1.24% 1
Kazakhstan Kazakhstan 6.72 +31% 9
Kyrgyzstan Kyrgyzstan 4.19 -0.238% 35
St. Kitts & Nevis St. Kitts & Nevis 4.32 0% 32
South Korea South Korea 12.7 +1.85% 2
Kuwait Kuwait 2.35 +17.5% 65
Laos Laos 1.27 -24.9% 87
Lebanon Lebanon 2.73 0% 56
Libya Libya 3.2 0% 45
St. Lucia St. Lucia 1.74 +32.8% 76
Sri Lanka Sri Lanka 4.02 +0.5% 37
Lithuania Lithuania 5.96 -4.18% 14
Luxembourg Luxembourg 4.19 -1.64% 35
Latvia Latvia 5.3 -2.21% 21
Morocco Morocco 0.73 +4.29% 100
Moldova Moldova 5.57 -3.97% 18
Maldives Maldives 5.04 -20.8% 22
Mexico Mexico 1 +3.09% 96
North Macedonia North Macedonia 4.22 +0.716% 34
Malta Malta 4.38 +6.57% 30
Myanmar (Burma) Myanmar (Burma) 1.06 +1.92% 94
Montenegro Montenegro 3.81 0% 40
Mongolia Mongolia 8.22 +3.53% 3
Mozambique Mozambique 0.7 -1.41% 102
Mauritius Mauritius 3.64 +0.275% 41
Malaysia Malaysia 1.97 +1.55% 73
Niger Niger 0.27 -6.9% 109
Nicaragua Nicaragua 0.94 -2.08% 98
Netherlands Netherlands 2.91 -3.64% 52
Norway Norway 3.4 -2.02% 43
Nepal Nepal 0.28 -3.45% 108
New Zealand New Zealand 2.51 -1.57% 61
Oman Oman 1.16 +5.45% 89
Panama Panama 1.92 -1.03% 75
Peru Peru 1.64 +3.8% 79
Philippines Philippines 0.99 +1.02% 97
Poland Poland 6.11 +0.328% 12
Portugal Portugal 3.53 +0.57% 42
Paraguay Paraguay 1.01 +12.2% 95
Romania Romania 7.06 +0.857% 7
Russia Russia 7.08 +0.141% 6
Rwanda Rwanda 0.74 +2.78% 99
Saudi Arabia Saudi Arabia 2.18 +1.4% 69
Sudan Sudan 0.66 0% 103
Singapore Singapore 2.63 +1.15% 58
El Salvador El Salvador 1.08 +1.89% 93
Serbia Serbia 5.35 +0.187% 20
Suriname Suriname 2.89 +6.25% 53
Slovakia Slovakia 5.68 -1.39% 15
Slovenia Slovenia 4.25 -2.97% 33
Sweden Sweden 2.05 -0.966% 71
Seychelles Seychelles 3.19 -1.85% 46
Syria Syria 1.39 +10.3% 83
Thailand Thailand 2.33 +4.95% 66
Tajikistan Tajikistan 4.36 +0.23% 31
Turkmenistan Turkmenistan 4.09 -0.969% 36
Trinidad & Tobago Trinidad & Tobago 1.92 +1.05% 75
Tunisia Tunisia 2.38 +33% 64
Turkey Turkey 2.99 +5.28% 50
Tanzania Tanzania 0.63 +3.28% 104
Ukraine Ukraine 6.26 -6.15% 11
Uruguay Uruguay 2.49 +0.81% 62
United States United States 2.74 -0.364% 55
Uzbekistan Uzbekistan 4.78 +2.8% 26
St. Vincent & Grenadines St. Vincent & Grenadines 3.98 +0.505% 38
Venezuela Venezuela 0.99 +6.45% 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 = 'SH.MED.BEDS.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 <- 'SH.MED.BEDS.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))