Last active
March 25, 2020 00:32
-
-
Save nim65s/808cc6d70dfb4ad258ec188cf5615efd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
Author
nim65s
commented
Mar 25, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment