here a small definition that uses Python and GH to query public databases for coronavirus cases and provides that data for further analysis. It’s inspired by this video by Luciano Ambrosini.
The data of some countries actually starts to look quite good.
There’s also a part that uses JSON to query the Italian more-up-to-date repository. It will prove useful for a sample in case your local data is provided in that format.
Finally, this definition purposely does not use any add-ons. However, your charts will look more beautiful with some third-party library, for example Human UI.
Note: any responsibility on decisions taken based on this data or definition is disclaimed.
It’s the (here daily) increment of the number of the first graph (1st derivative) and the rate by which the increment is modifying (2nd derivative). These show the trends, basically. They suffer of statistical error.
The derivative tells you how a function (in this case a sampled distribution) change at any position. If A and B are points, the change from A to B is (A-B) / dt, where dt is the change in time. So in case of the change of a position, the derivative is its velocity. And the derivative of the derivative, or second derivative, is how its velocity changes, ie, its acceleration.
Thanks @piac! Here’s an update that combines combines US counties into state summaries when join_regions is false, and rolls up by country when join_regions is true. Early data in the US was by county, and is now aggregated by state, so the overall time-period graphs for either didn’t make sense.
Ok so these (python) components are from Giulio Piacentino… I’m not on the same python level
But as I understand it, there is a mistake in the data, where information is missing (empty spot in one list that does not convert to integer). That maybe could be fixed by some python magicians (any idea @piac ?)
While waiting for that, as a python noob, when there are errors, I simply pass them
Here is a working version… This should be ok, but I don’t really know what is being thrown by my “try/except” combo. (if anyone could enlighten me, please do !) coronavirus-data_AMA.gh (39.1 KB)
from io import StringIO as s
import csv
import ghpythonlib.treehelpers as th
f = s(x)
reader = csv.reader(f, delimiter=',')
results = dict()
count = -1
for row in reader:
count += 1
if count == 0: continue
Province_State_Country = row[1] if join_regions else row[0]
if not Province_State_Country: Province_State_Country = row[1]
if not join_regions and Province_State_Country != row[1]: Province_State_Country = row[1] + ", " + Province_State_Country
raw_vals = row[4:]
if Province_State_Country in results:
prevs = results[Province_State_Country]
#print(raw_vals)
try:
extra = [(int(c) + prevs[i]) for (i,c) in enumerate(raw_vals)]
except (ValueError):
pass
values = extra
#
else:
try:
values = [int(c) for c in raw_vals]
except(ValueError):
pass
results[Province_State_Country] = values
results = sorted(results.items(), key = lambda kv: kv[0])
a = [n[0] for n in results]
b = th.list_to_tree([n[1] for n in results])