application_vnd.jupyter.stderr_output_1.png image_output_1.png
from datetime import timedelta

from matplotlib.dates import WeekdayLocator, DateFormatter

import matplotlib.pyplot as plt

import pandas as pd

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

covid19 = pd.read_csv('/kaggle/input/hospital-resources-during-covid19-pandemic/Hospitalization_all_locs.csv', parse_dates=['date'], usecols=['location_name', 'date', 'allbed_mean', 'ICUbed_mean', 'InvVen_mean'])

covid19.rename(columns={'location_name': 'state'}, inplace=True)
states_list = ['New York', 'Louisiana', 'Washington', 'California', 'Alabama']
covid19 = covid19[covid19['state'].isin(states_list)].copy()

covid19['Resources'] = covid19.loc[:, ['allbed_mean', 'ICUbed_mean', 'InvVen_mean']].sum(axis=1).div(1000)

fig, ax = plt.subplots(figsize=(20, 10))
for st in states_list:
    ax.plot(covid19[covid19.state == st].date, covid19[covid19.state == st].Resources, label=st)
ax.xaxis.set_major_locator(WeekdayLocator())
ax.xaxis.set_major_formatter(DateFormatter('%b %d'))
min_date = covid19.date[covid19.Resources != 0].min().date() - timedelta(days=7)
max_date = covid19.date[covid19.Resources != 0].max().date() + timedelta(days=7)
ax.set_xlim(min_date, max_date)
fig.autofmt_xdate()
ax.legend()
font_size = 14
plt.title('The hospital resources needed for COVID-19 patients across 5 different US States', fontsize=font_size + 2)
plt.ylabel('Total Resource Count (k)', fontsize=font_size)
plt.xlabel('Date', fontsize=font_size)
plt.show()
fig.savefig('Hospital_resource_use.png', bbox_inches='tight')