Skip to content

Instantly share code, notes, and snippets.

@nim65s
Last active March 25, 2020 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nim65s/808cc6d70dfb4ad258ec188cf5615efd to your computer and use it in GitHub Desktop.
Save nim65s/808cc6d70dfb4ad258ec188cf5615efd to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from csv import reader
from datetime import date, timedelta
from os.path import isfile
import matplotlib.pyplot as plt
import requests
FILE = 'time_series_covid19_deaths_global.csv'
URL = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/'
START = 23 # days after first data to get non-zero
COUNTRIES = {'Italy': [], 'Spain': [], 'France': [], 'United Kingdom': [], 'Korea, South': [], 'Germany': []}
if not isfile(FILE):
with open(FILE, 'wb') as f:
f.write(requests.get(URL + FILE).content)
with open(FILE) as csv:
for row in reader(csv):
if row[1] in COUNTRIES.keys() and row[0] in ('', row[1]):
COUNTRIES[row[1]] = [int(day) for day in row[4 + START:]]
DAYS = [date(2020, 1, 22) + timedelta(days=START + i) for i in range(len(COUNTRIES['France']))]
for name, vals in COUNTRIES.items():
plt.plot(DAYS, vals, label=f'{name}: {vals[-1]}')
plt.title('Deaths')
plt.yscale('log')
plt.grid(True, 'both', 'y')
plt.legend()
plt.show()
@nim65s
Copy link
Author

nim65s commented Mar 25, 2020

Figure_1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment