image_output_1.png
import geopandas as gpd

import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import numpy as np
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
df_countries = pd.read_csv('/kaggle/input/countries-iso-codes/wikipedia-iso-country-codes.csv')
df_global = pd.read_csv('/kaggle/input/global-hospital-beds-capacity-for-covid19/hospital_beds_global_v1.csv')
df_global.dataframeName = 'hospital_beds_global_v1.csv'
df_global = df_global.merge(df_countries, how='left', left_on=['country'], right_on=['Alpha-2 code'])
df_global.rename(columns={'Alpha-3 code': 'country code', 'English short name lower case': 'country name'}, inplace=True)
df_global = df_global[['country name', 'country code', 'beds', 'type', 'year', 'population']]

world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))

df_global_acute = df_global[df_global['type'] == 'ACUTE']

mapped = world.merge(df_global_acute[['country code', 'beds']], how='left', left_on='iso_a3', right_on='country code')
mapped = mapped.fillna(0)

to_be_mapped = 'beds'
vmin, vmax = 0,df_global_acute['beds'].max()
fig, ax = plt.subplots(1, figsize=(25,25))

mapped.plot(column=to_be_mapped, cmap='Blues', linewidth=0.8, ax=ax, edgecolors='0.8')
ax.set_title('Number of ACUTE beds per 1000 inhabitants in countries', fontdict={'fontsize':30})
ax.set_axis_off()

sm = plt.cm.ScalarMappable(cmap='Blues', norm=plt.Normalize(vmin=vmin, vmax=vmax))
sm._A = []

cbar = fig.colorbar(sm, orientation='horizontal')

df_global_icu = df_global[df_global['type'] == 'ICU']

mapped = world.merge(df_global_icu[['country code', 'beds']], how='left', left_on='iso_a3', right_on='country code')
mapped = mapped.fillna(0)

to_be_mapped = 'beds'
vmin, vmax = 0,df_global_icu['beds'].max()
fig, ax = plt.subplots(1, figsize=(25,25))

mapped.plot(column=to_be_mapped, cmap='Blues', linewidth=0.8, ax=ax, edgecolors='0.8')
ax.set_title('Number of ICU beds per 1000 inhabitants in countries', fontdict={'fontsize':30})
ax.set_axis_off()

sm = plt.cm.ScalarMappable(cmap='Blues', norm=plt.Normalize(vmin=vmin, vmax=vmax))
sm._A = []

cbar = fig.colorbar(sm, orientation='horizontal')

df_global_total = df_global[df_global['type'] == 'TOTAL']
mapped = world.merge(df_global_icu[['country code', 'beds']], how='left', left_on='iso_a3', right_on='country code')
mapped = mapped.fillna(0)
to_be_mapped = 'beds'
vmin, vmax = (0, df_global_total['beds'].max())
fig, ax = plt.subplots(1, figsize=(25, 25))
mapped.plot(column=to_be_mapped, cmap='Blues', linewidth=0.8, ax=ax, edgecolors='0.8')
ax.set_title('Number of TOTAL beds per 1000 inhabitants in countries', fontdict={'fontsize': 30})
ax.set_axis_off()
sm = plt.cm.ScalarMappable(cmap='Blues', norm=plt.Normalize(vmin=vmin, vmax=vmax))
sm._A = []
cbar = fig.colorbar(sm, orientation='horizontal')