application_vnd.jupyter.stderr_output_1.png image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

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

data_path = '/kaggle/input/covid19-global-forecasting-week-4/train.csv'
data_train = pd.read_csv(data_path)

confirmed_total_date_Italy = data_train[data_train['Country_Region'] == 'Italy'].groupby(['Date']).agg({'ConfirmedCases': ['sum']})
fatalities_total_date_Italy = data_train[data_train['Country_Region'] == 'Italy'].groupby(['Date']).agg({'Fatalities': ['sum']})
total_date_Italy = confirmed_total_date_Italy.join(fatalities_total_date_Italy)
plt.figure(figsize=(17, 10))
plt.subplot(2, 2, 1)
total_date_Italy.plot(ax=plt.gca(), title='Italy')
plt.ylabel('Confirmed infection cases', size=13)
confirmed_total_date_US = data_train[data_train['Country_Region'] == 'US'].groupby(['Date']).agg({'ConfirmedCases': ['sum']})
fatalities_total_date_US = data_train[data_train['Country_Region'] == 'US'].groupby(['Date']).agg({'Fatalities': ['sum']})
total_date_US = confirmed_total_date_US.join(fatalities_total_date_US)
plt.subplot(2, 2, 2)
total_date_US.plot(ax=plt.gca(), title='US')
plt.ylabel('Confirmed infection cases', size=13)
confirmed_total_date_Spain = data_train[data_train['Country_Region'] == 'Spain'].groupby(['Date']).agg({'ConfirmedCases': ['sum']})
fatalities_total_date_Spain = data_train[data_train['Country_Region'] == 'Spain'].groupby(['Date']).agg({'Fatalities': ['sum']})
total_date_Spain = confirmed_total_date_Spain.join(fatalities_total_date_Spain)
plt.subplot(2, 2, 3)
total_date_Spain.plot(ax=plt.gca(), title='Spain')
plt.ylabel('Confirmed infection cases', size=13)
confirmed_total_date_Korea = data_train[data_train['Country_Region'] == 'Korea, South'].groupby(['Date']).agg({'ConfirmedCases': ['sum']})
fatalities_total_date_Korea = data_train[data_train['Country_Region'] == 'Korea, South'].groupby(['Date']).agg({'Fatalities': ['sum']})
total_date_Korea = confirmed_total_date_Korea.join(fatalities_total_date_Korea)
plt.subplot(2, 2, 4)
total_date_Korea.plot(ax=plt.gca(), title='Korea, South')
plt.ylabel('Confirmed infection cases', size=13)
plt.figure(figsize=(17, 10))
plt.subplot(2, 2, 1)
plt.plot(confirmed_total_date_Italy)
plt.plot(confirmed_total_date_US)
plt.plot(confirmed_total_date_Spain)
plt.plot(confirmed_total_date_Korea)
plt.legend(['Italy', 'US', 'Spain', 'Korea, South'], loc='upper left')
plt.title('COVID-19 infections from the first confirmed case', size=15)
plt.xlabel('Days', size=13)
plt.ylabel('Infected cases', size=13)
plt.ylim(0, 180000)
plt.subplot(2, 2, 2)
plt.plot(fatalities_total_date_Italy)
plt.plot(fatalities_total_date_US)
plt.plot(fatalities_total_date_Spain)
plt.plot(fatalities_total_date_Korea)
plt.legend(['Italy', 'US', 'Spain', 'Korea, South'], loc='upper left')
plt.title('COVID-19 Fatalities', size=15)
plt.xlabel('Days', size=13)
plt.ylabel('Infected cases', size=13)
plt.ylim(0, 23000)
plt.show()