projects
/
python.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
73ff8fe
)
Update.
author
Francois Fleuret
<francois@fleuret.org>
Thu, 12 Mar 2020 16:31:29 +0000
(17:31 +0100)
committer
Francois Fleuret
<francois@fleuret.org>
Thu, 12 Mar 2020 16:31:29 +0000
(17:31 +0100)
covid19.py
patch
|
blob
|
history
diff --git
a/covid19.py
b/covid19.py
index
ea79544
..
ef9e393
100755
(executable)
--- a/
covid19.py
+++ b/
covid19.py
@@
-5,7
+5,7
@@
# Written by Francois Fleuret <francois@fleuret.org>
# Written by Francois Fleuret <francois@fleuret.org>
-import os, time
, math
+import os, time
import numpy, csv
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import numpy, csv
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
@@
-13,7
+13,7
@@
import urllib.request
url = 'https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv'
url = 'https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv'
-file =
'time_series_19-covid-Confirmed.csv'
+file =
url[url.rfind('/')+1:]
######################################################################
######################################################################
@@
-36,13
+36,16
@@
with open(file, newline='') as csvfile:
nb_cases[country] = numpy.zeros(len(times))
if row_nb == 0 and col_nb >= time_col:
times.append(time.mktime(time.strptime(field, '%m/%d/%y')))
nb_cases[country] = numpy.zeros(len(times))
if row_nb == 0 and col_nb >= time_col:
times.append(time.mktime(time.strptime(field, '%m/%d/%y')))
- if row_nb == 1 and col_nb == time_col:
- nb_cases['World'] = numpy.zeros(len(times))
if row_nb >= 1:
if col_nb >= time_col:
if row_nb >= 1:
if col_nb >= time_col:
- nb_cases['World'][col_nb - time_col] += int(field)
nb_cases[country][col_nb - time_col] += int(field)
nb_cases[country][col_nb - time_col] += int(field)
+countries = list(nb_cases.keys())
+countries.sort()
+print('Countries: ', countries)
+
+nb_cases['World'] = sum(nb_cases.values())
+
######################################################################
fig = plt.figure()
######################################################################
fig = plt.figure()
@@
-54,12
+57,10
@@
ax.set_xlabel('Date', labelpad = 10)
ax.set_yscale('log')
myFmt = mdates.DateFormatter('%b %d')
ax.set_yscale('log')
myFmt = mdates.DateFormatter('%b %d')
+
ax.xaxis.set_major_formatter(myFmt)
dates = mdates.epoch2num(times)
ax.xaxis.set_major_formatter(myFmt)
dates = mdates.epoch2num(times)
-print('Countries:')
-print(nb_cases.keys())
-
for key, color, label in [
('World', 'blue', 'World'),
('Switzerland', 'red', 'Switzerland'),
for key, color, label in [
('World', 'blue', 'World'),
('Switzerland', 'red', 'Switzerland'),
@@
-74,6
+75,7
@@
for key, color, label in [
ax.legend(frameon = False)
plt.show()
ax.legend(frameon = False)
plt.show()
+
fig.savefig('covid19.png')
######################################################################
fig.savefig('covid19.png')
######################################################################