Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
confirmed=pd.read_csv('COVID-19/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv').set_index(['Province/State' , 'Country/Region','Lat' , 'Long']).fillna(0)
recovered=pd.read_csv('COVID-19/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv').set_index(['Province/State' , 'Country/Region','Lat' , 'Long']).fillna(0)
deaths=pd.read_csv('COVID-19/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv').set_index(['Province/State' , 'Country/Region','Lat' , 'Long']).fillna(0)
dates = [datetime.strptime(d,"%m/%d/%y").date() for d in confirmed.columns]
ger_con=confirmed.loc[(slice(None),'Germany'),].values[0]
ger_rec=recovered.loc[(slice(None),'Germany'),].values[0]
ger_dea=deaths.loc[(slice(None),'Germany'),].values[0]
def new_cases(country,what):
timeseries=[0]+what.loc[(slice(None),country),].values.sum(0)
return [timeseries[i+1]-xi for i, xi in enumerate(timeseries[:-1])]
countries=['Germany', 'Italy', 'China','France','Spain', 'US']
europe=['Germany', 'Italy','France','Spain', 'Swiss', 'Norway', 'Denmark', 'Netherlands']
#plt.plot(dates, ger_con)
for country in countries:
plt.plot(dates, confirmed.loc[(slice(None),country),].values.sum(0), label=country)
plt.legend()
plt.yscale('log')
plt.grid()
plt.xticks(rotation=45, ha='right')
plt.show()
for country in countries:
plt.plot(dates, deaths.loc[(slice(None),country),].values.sum(0), label=country)
plt.legend()
plt.yscale('log')
plt.grid()
plt.xticks(rotation=45, ha='right')
plt.show()
for country in countries+[europe]:
plt.plot(dates, confirmed.loc[(slice(None),country),].values.sum(0), label='confirmed')
plt.plot(dates, recovered.loc[(slice(None),country),].values.sum(0), label='recovered')
plt.plot(dates, deaths.loc[(slice(None),country),].values.sum(0), label='deaths')
plt.yscale('log')
plt.legend()
plt.title(country)
plt.grid()
plt.xticks(rotation=45, ha='right')
plt.savefig(f'covid_{country}_cases.png')
plt.show()