In [1]:
%load_ext watermark
%watermark -a 'cs224' -u -d -v -p numpy,xarray,scipy,pandas,sklearn,matplotlib,seaborn,pymc3
cs224 
last updated: 2020-08-03 

CPython 3.6.10
IPython 7.15.0

numpy 1.18.5
xarray 0.15.1
scipy 1.5.0
pandas 1.0.5
sklearn 0.23.1
matplotlib 3.2.2
seaborn 0.10.1
pymc3 3.9.2
In [2]:
%matplotlib inline
import numpy as np, scipy, scipy.stats as stats, scipy.special, scipy.misc, pandas as pd, matplotlib.pyplot as plt, seaborn as sns, xarray as xr
import matplotlib as mpl

import pymc3 as pm

import theano as thno
import theano.tensor as T

import sklearn, sklearn.linear_model

import datetime, time, math
from dateutil import relativedelta

from collections import OrderedDict

SEED = 42
np.random.seed(SEED)

pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
# pd.set_option('display.float_format', lambda x: '%.2f' % x)
np.set_printoptions(edgeitems=10)
np.set_printoptions(linewidth=1000)
np.set_printoptions(suppress=True)
np.core.arrayprint._line_width = 180

sns.set()
# sns.set_style("whitegrid")
In [3]:
from IPython.display import display, HTML

from IPython.display import display_html
def display_side_by_side(*args):
    html_str=''
    for df in args:
        if type(df) == np.ndarray:
            df = pd.DataFrame(df)
        html_str+=df.to_html()
    html_str = html_str.replace('table','table style="display:inline"')
    # print(html_str)
    display_html(html_str,raw=True)

CSS = """
.output {
    flex-direction: row;
}
"""

def display_graphs_side_by_side(*args):
    html_str='<table><tr>'
    for g in args:
        html_str += '<td>'
        html_str += g._repr_svg_()
        html_str += '</td>'
    html_str += '</tr></table>'
    display_html(html_str,raw=True)
    

display(HTML("<style>.container { width:70% !important; }</style>"))
In [4]:
%load_ext autoreload
%autoreload 1
%aimport covid19

Data Source: CSSEGISandData/COVID-19, the data behind the dashboard: Coronavirus COVID-19 Global Cases by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University (JHU).

It seems that there are currently data-changes in progress that cause issues. This is mostly an issue for the US data, so that I comment it out. The US data as used in this notebook is currently wrong.

In [5]:
covid19.time_series_19_covid_confirmed.head()
Out[5]:
Province/State Country/Region Lat Long 1/22/20 1/23/20 1/24/20 1/25/20 1/26/20 1/27/20 1/28/20 1/29/20 1/30/20 1/31/20 2/1/20 2/2/20 2/3/20 2/4/20 2/5/20 2/6/20 2/7/20 2/8/20 2/9/20 2/10/20 2/11/20 2/12/20 2/13/20 2/14/20 2/15/20 2/16/20 2/17/20 2/18/20 2/19/20 2/20/20 2/21/20 2/22/20 2/23/20 2/24/20 2/25/20 2/26/20 2/27/20 2/28/20 2/29/20 3/1/20 3/2/20 3/3/20 3/4/20 3/5/20 3/6/20 3/7/20 3/8/20 3/9/20 3/10/20 3/11/20 3/12/20 3/13/20 3/14/20 3/15/20 3/16/20 3/17/20 3/18/20 3/19/20 3/20/20 3/21/20 3/22/20 3/23/20 3/24/20 3/25/20 3/26/20 3/27/20 3/28/20 3/29/20 3/30/20 3/31/20 4/1/20 4/2/20 4/3/20 4/4/20 4/5/20 4/6/20 4/7/20 4/8/20 4/9/20 4/10/20 4/11/20 4/12/20 4/13/20 4/14/20 4/15/20 4/16/20 4/17/20 4/18/20 4/19/20 4/20/20 4/21/20 4/22/20 4/23/20 4/24/20 4/25/20 4/26/20 4/27/20 4/28/20 4/29/20 4/30/20 5/1/20 5/2/20 5/3/20 5/4/20 5/5/20 5/6/20 5/7/20 5/8/20 5/9/20 5/10/20 5/11/20 5/12/20 5/13/20 5/14/20 5/15/20 5/16/20 5/17/20 5/18/20 5/19/20 5/20/20 5/21/20 5/22/20 5/23/20 5/24/20 5/25/20 5/26/20 5/27/20 5/28/20 5/29/20 5/30/20 5/31/20 6/1/20 6/2/20 6/3/20 6/4/20 6/5/20 6/6/20 6/7/20 6/8/20 6/9/20 6/10/20 6/11/20 6/12/20 6/13/20 6/14/20 6/15/20 6/16/20 6/17/20 6/18/20 6/19/20 6/20/20 6/21/20 6/22/20 6/23/20 6/24/20 6/25/20 6/26/20 6/27/20 6/28/20 6/29/20 6/30/20 7/1/20 7/2/20 7/3/20 7/4/20 7/5/20 7/6/20 7/7/20 7/8/20 7/9/20 7/10/20 7/11/20 7/12/20 7/13/20 7/14/20 7/15/20 7/16/20 7/17/20 7/18/20 7/19/20 7/20/20 7/21/20 7/22/20 7/23/20 7/24/20 7/25/20 7/26/20 7/27/20 7/28/20 7/29/20 7/30/20 7/31/20 8/1/20 8/2/20
0 NaN Afghanistan 33.93911 67.709953 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 4 4 5 7 7 7 11 16 21 22 22 22 24 24 40 40 74 84 94 110 110 120 170 174 237 273 281 299 349 367 423 444 484 521 555 607 665 714 784 840 906 933 996 1026 1092 1176 1279 1351 1463 1531 1703 1828 1939 2171 2335 2469 2704 2894 3224 3392 3563 3778 4033 4402 4687 4963 5226 5639 6053 6402 6664 7072 7653 8145 8676 9216 9998 10582 11173 11831 12456 13036 13659 14525 15205 15750 16509 17267 18054 18969 19551 20342 20917 21459 22142 22890 23546 24102 24766 25527 26310 26874 27532 27878 28424 28833 29157 29481 29640 30175 30451 30616 30967 31238 31517 31836 32022 32324 32672 32951 33190 33384 33594 33908 34194 34366 34451 34455 34740 34994 35070 35229 35301 35475 35526 35615 35727 35928 35981 36036 36157 36263 36368 36471 36542 36675 36710 36710
1 NaN Albania 41.15330 20.168300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 10 12 23 33 38 42 51 55 59 64 70 76 89 104 123 146 174 186 197 212 223 243 259 277 304 333 361 377 383 400 409 416 433 446 467 475 494 518 539 548 562 584 609 634 663 678 712 726 736 750 766 773 782 789 795 803 820 832 842 850 856 868 872 876 880 898 916 933 946 948 949 964 969 981 989 998 1004 1029 1050 1076 1099 1122 1137 1143 1164 1184 1197 1212 1232 1246 1263 1299 1341 1385 1416 1464 1521 1590 1672 1722 1788 1838 1891 1962 1995 2047 2114 2192 2269 2330 2402 2466 2535 2580 2662 2752 2819 2893 2964 3038 3106 3188 3278 3371 3454 3571 3667 3752 3851 3906 4008 4090 4171 4290 4358 4466 4570 4637 4763 4880 4997 5105 5197 5276 5396 5519
2 NaN Algeria 28.03390 1.659600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 3 5 12 12 17 17 19 20 20 20 24 26 37 48 54 60 74 87 90 139 201 230 264 302 367 409 454 511 584 716 847 986 1171 1251 1320 1423 1468 1572 1666 1761 1825 1914 1983 2070 2160 2268 2418 2534 2629 2718 2811 2910 3007 3127 3256 3382 3517 3649 3848 4006 4154 4295 4474 4648 4838 4997 5182 5369 5558 5723 5891 6067 6253 6442 6629 6821 7019 7201 7377 7542 7728 7918 8113 8306 8503 8697 8857 8997 9134 9267 9394 9513 9626 9733 9831 9935 10050 10154 10265 10382 10484 10589 10698 10810 10919 11031 11147 11268 11385 11504 11631 11771 11920 12076 12248 12445 12685 12968 13273 13571 13907 14272 14657 15070 15500 15941 16404 16879 17348 17808 18242 18712 19195 19689 20216 20770 21355 21948 22549 23084 23691 24278 24872 25484 26159 26764 27357 27973 28615 29229 29831 30394 30950 31465
3 NaN Andorra 42.50630 1.521800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 39 39 53 75 88 113 133 164 188 224 267 308 334 370 376 390 428 439 466 501 525 545 564 583 601 601 638 646 659 673 673 696 704 713 717 717 723 723 731 738 738 743 743 743 745 745 747 748 750 751 751 752 752 754 755 755 758 760 761 761 761 761 761 761 762 762 762 762 762 763 763 763 763 764 764 764 765 844 851 852 852 852 852 852 852 852 852 853 853 853 853 854 854 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 858 861 862 877 880 880 880 884 884 889 889 897 897 897 907 907 918 922 925 925 925
4 NaN Angola -11.20270 17.873900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 3 3 3 4 4 5 7 7 7 8 8 8 10 14 16 17 19 19 19 19 19 19 19 19 19 19 24 24 24 24 25 25 25 25 26 27 27 27 27 30 35 35 35 36 36 36 43 43 45 45 45 45 48 48 48 48 50 52 52 58 60 61 69 70 70 71 74 81 84 86 86 86 86 86 86 88 91 92 96 113 118 130 138 140 142 148 155 166 172 176 183 186 189 197 212 212 259 267 276 284 291 315 328 346 346 346 386 386 396 458 462 506 525 541 576 607 638 687 705 749 779 812 851 880 916 932 950 1000 1078 1109 1148 1164 1199
In [6]:
covid19.time_series_19_covid_recovered.head()
Out[6]:
Province/State Country/Region Lat Long 1/22/20 1/23/20 1/24/20 1/25/20 1/26/20 1/27/20 1/28/20 1/29/20 1/30/20 1/31/20 2/1/20 2/2/20 2/3/20 2/4/20 2/5/20 2/6/20 2/7/20 2/8/20 2/9/20 2/10/20 2/11/20 2/12/20 2/13/20 2/14/20 2/15/20 2/16/20 2/17/20 2/18/20 2/19/20 2/20/20 2/21/20 2/22/20 2/23/20 2/24/20 2/25/20 2/26/20 2/27/20 2/28/20 2/29/20 3/1/20 3/2/20 3/3/20 3/4/20 3/5/20 3/6/20 3/7/20 3/8/20 3/9/20 3/10/20 3/11/20 3/12/20 3/13/20 3/14/20 3/15/20 3/16/20 3/17/20 3/18/20 3/19/20 3/20/20 3/21/20 3/22/20 3/23/20 3/24/20 3/25/20 3/26/20 3/27/20 3/28/20 3/29/20 3/30/20 3/31/20 4/1/20 4/2/20 4/3/20 4/4/20 4/5/20 4/6/20 4/7/20 4/8/20 4/9/20 4/10/20 4/11/20 4/12/20 4/13/20 4/14/20 4/15/20 4/16/20 4/17/20 4/18/20 4/19/20 4/20/20 4/21/20 4/22/20 4/23/20 4/24/20 4/25/20 4/26/20 4/27/20 4/28/20 4/29/20 4/30/20 5/1/20 5/2/20 5/3/20 5/4/20 5/5/20 5/6/20 5/7/20 5/8/20 5/9/20 5/10/20 5/11/20 5/12/20 5/13/20 5/14/20 5/15/20 5/16/20 5/17/20 5/18/20 5/19/20 5/20/20 5/21/20 5/22/20 5/23/20 5/24/20 5/25/20 5/26/20 5/27/20 5/28/20 5/29/20 5/30/20 5/31/20 6/1/20 6/2/20 6/3/20 6/4/20 6/5/20 6/6/20 6/7/20 6/8/20 6/9/20 6/10/20 6/11/20 6/12/20 6/13/20 6/14/20 6/15/20 6/16/20 6/17/20 6/18/20 6/19/20 6/20/20 6/21/20 6/22/20 6/23/20 6/24/20 6/25/20 6/26/20 6/27/20 6/28/20 6/29/20 6/30/20 7/1/20 7/2/20 7/3/20 7/4/20 7/5/20 7/6/20 7/7/20 7/8/20 7/9/20 7/10/20 7/11/20 7/12/20 7/13/20 7/14/20 7/15/20 7/16/20 7/17/20 7/18/20 7/19/20 7/20/20 7/21/20 7/22/20 7/23/20 7/24/20 7/25/20 7/26/20 7/27/20 7/28/20 7/29/20 7/30/20 7/31/20 8/1/20 8/2/20
0 NaN Afghanistan 33.93911 67.709953 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 5 5 10 10 10 15 18 18 29 32 32 32 32 32 40 43 54 99 112 131 135 150 166 179 188 188 207 220 228 252 260 310 331 345 397 421 458 468 472 502 558 558 610 648 691 745 745 778 801 850 930 938 996 1040 1075 1097 1128 1138 1209 1259 1303 1328 1428 1450 1522 1585 1762 1830 1875 2171 2651 3013 3326 3928 4201 4725 5164 5508 6158 7660 7962 8292 8764 8841 9260 9869 10174 10306 10674 12604 13934 14131 15651 16041 17331 19164 19366 20103 20179 20700 20847 20882 21135 21216 21254 21454 22456 22824 23151 23273 23634 23741 23741 23924 24550 24602 24793 25180 25198 25358 25389 25471 25509 25509 25510
1 NaN Albania 41.15330 20.168300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 10 17 17 31 31 33 44 52 67 76 89 99 104 116 131 154 165 182 197 217 232 248 251 277 283 302 314 327 345 356 385 394 403 410 422 431 455 470 488 519 531 543 570 595 605 620 627 650 654 682 688 694 705 714 715 727 742 758 771 777 783 789 795 803 812 823 851 857 872 877 891 898 898 910 925 938 945 960 980 1001 1034 1039 1044 1055 1064 1077 1086 1114 1126 1134 1159 1195 1217 1250 1298 1346 1384 1438 1459 1516 1559 1592 1637 1657 1702 1744 1791 1832 1875 1881 1946 2014 2062 2091 2137 2214 2264 2311 2352 2397 2463 2523 2608 2637 2682 2745 2789 2830 2883 2952 2961 3018
2 NaN Algeria 28.03390 1.659600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 8 12 12 12 12 12 32 32 32 65 65 24 65 29 29 31 31 37 46 61 61 62 90 90 90 113 237 347 405 460 591 601 691 708 783 846 894 1047 1099 1152 1204 1355 1408 1479 1508 1558 1651 1702 1779 1821 1872 1936 1998 2067 2197 2323 2467 2546 2678 2841 2998 3058 3158 3271 3409 3507 3625 3746 3968 4062 4256 4426 4784 4747 4918 5129 5277 5422 5549 5748 5894 6067 6218 6297 6453 6631 6717 6799 6951 7074 7255 7322 7420 7606 7735 7842 7943 8078 8196 8324 8422 8559 8674 8792 8920 9066 9202 9371 9674 9897 10040 10342 10832 11181 11492 11884 12094 12329 12637 13124 13124 13743 14019 14295 14792 15107 15430 15744 16051 16400 16646 16983 17369 17369 18076 18088 18837 19233 19592 20082 20537 20988 21419
3 NaN Andorra 42.50630 1.521800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 10 10 10 16 21 26 31 39 52 58 71 71 128 128 128 169 169 191 205 235 248 282 309 333 344 344 344 385 398 423 468 468 472 493 499 514 521 526 537 545 550 550 568 576 596 604 615 617 624 628 639 639 652 653 653 663 676 676 681 684 692 694 698 733 735 738 741 741 744 751 757 759 780 781 781 781 789 789 791 792 792 792 792 796 797 797 797 799 799 799 799 799 799 800 800 800 800 800 800 802 802 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 804 806 807 807 807
4 NaN Angola -11.20270 17.873900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 2 2 2 2 2 2 2 4 4 4 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 7 7 11 11 11 11 11 11 11 11 13 13 13 13 14 14 17 17 17 17 17 17 17 17 18 18 18 18 18 18 18 18 18 18 18 18 18 21 24 24 38 38 40 41 42 61 61 64 64 64 64 66 66 77 77 77 77 81 81 81 81 93 93 97 97 107 108 108 108 117 117 117 117 118 118 118 118 124 124 199 210 221 221 221 221 236 241 242 242 242 266 301 395 437 460 461
In [7]:
df = covid19.get_cases_by_region(region='China')
df.tail()
Out[7]:
confirmed recovered death new_confirmed new_recovered new_death
2020-07-29 87213 80594 4658 223 77 1
2020-07-30 87489 80680 4659 276 86 1
2020-07-31 87655 80787 4661 166 107 2
2020-08-01 87827 80907 4667 172 120 6
2020-08-02 87985 81018 4669 158 111 2
In [8]:
df = covid19.get_rki_df()
cbr_germany = covid19.CasesByRegion('Germany', df=df)
cbr_germany.tail()
Out[8]:
confirmed recovered death new_confirmed new_recovered new_death
index
2020-07-29 208959 193483 9135 595 0 4
2020-07-30 209486 193483 9144 527 0 9
2020-07-31 210009 193483 9147 523 0 3
2020-08-01 210305 193483 9154 296 0 7
2020-08-02 210395 193483 9154 90 0 0
In [9]:
cbr_germany.plot_daily_stats()
Out[9]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f20e5191be0>

COVID-19-Pandemie#Deutschland:

Am 22. März 2020 einigten sich Bund und Länder auf ein „umfassendes Kontaktverbot“, statt weitergehende Ausgangssperren zu beschließen.

Roughly 2020-04-21 the taken actions show clear effect; roughly 4.5 weeks later.

prediction date predicted day for reaching 100 threshold predicted max growth rate steady state rate
2020-04-02 2020-04-21 92845 0.057 -
2020-04-03 2020-04-23 99774 0.054 -
2020-04-04 2020-04-25 107193 0.051 -
2020-04-05 2020-04-27 114511 0.049 -
2020-04-06 2020-04-29 119618 0.045 -
2020-04-07 2020-04-29 121354 0.039 -
2020-04-08 2020-04-30 123011 0.035 -
2020-04-09 2020-04-30 125833 0.031 -
2020-04-10 - - 0.049 4820
2020-04-11 - - 0.042 4739
2020-04-12 - - 0.040 4570
2020-04-13 - - 0.036 4300
2020-04-14 - - 0.033 3927
2020-04-15 - - 0.029 3451
2020-04-16 - - 0.026 3086
2020-04-17 - - 0.024 2845
2020-04-19 - - 0.021 2666
2020-04-20 - - 0.020 2554
2020-04-21 - - 0.018 2356
2020-04-24 - - 0.015 2043
2020-04-25 2020-05-24 166654 0.011 -
2020-04-26 2020-05-26 167739 0.010 -
2020-04-27 2020-05-26 168771 0.009 -
2020-04-28 - - 0.013 1538
2020-04-29 2020-05-25 169856 0.008 -
2020-04-30 2020-05-26 170081 0.007 -
2020-05-01 2020-06-06 176154 0.007 -
2020-05-02 2020-06-06 176278 0.006 -
2020-05-03 2020-06-06 176466 0.006 -
2020-05-04 2020-06-06 176419 0.005 -
2020-05-09 2020-06-07 177511 0.004 -
2020-05-11 2020-06-07 177421 0.003 -
2020-05-12 2020-06-07 177954 0.003 -
2020-05-17 2020-06-08 179372 0.002 -
2020-05-24 2020-06-09 180945 0.002 -
2020-05-28 2020-06-10 180990 0.001 -
2020-05-29 - - 0.002 164
2020-06-07 - - 0.002 208
2020-06-14 - - 0.002 225
2020-06-24 - - 0.002 296
In [10]:
cbr_germany.fit(first_date=pd.to_datetime('2020-03-09'))
 /home/local/cs/workspaces/covid-19-data-analysis/covid19.py:1526: UserWarning:Exception in curve_fit: Optimal parameters not found: Number of calls to function has reached maxfev = 600./ None
In [11]:
# cbr_germany.fit_df0.loc[pd.to_datetime('2020-05-24')]
In [12]:
fig = plt.figure(figsize=(32,8), dpi=80, facecolor='w', edgecolor='k')
ax = plt.subplot(1,1,1)
cbr_germany.plot_with_fits(ax=ax, restriction_start_date=datetime.datetime(2020, 3, 22))
sigmoid+asymmetric+linear: seor: 303.88584981440266; growth-rate: 0.002, date:2020-09-10 00:00:00, projected value: 390.8530294495339
In [13]:
cbr_germany.fit_df0[['fit_diff']].apply(['max'])
Out[13]:
fit_diff
max 4867.318507
In [14]:
cbr_germany.calculate_R_estimates()
cbr_germany.R().round(3)
Out[14]:
fit_R gp_R kf_R ll_R mean_R
index
2020-07-31 0.998 0.843 0.737 0.894 0.912
In [15]:
fig = plt.figure(figsize=(32,8), dpi=80, facecolor='w', edgecolor='k')
ax = plt.subplot(1,1,1)
cbr_germany.plot_R(ax=ax) # , plot_start_date='2020-03-10'
Out[15]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f20e3ef18d0>
In [16]:
df = covid19.get_austria_df()
cbr_austria = covid19.CasesByRegion('Austria', df=df)
cbr_austria.tail()
Out[16]:
confirmed recovered death new_confirmed new_recovered new_death
index
2020-07-29 20832 18528 698 180 149 10
2020-07-30 20935 18628 698 103 100 0
2020-07-31 21110 18758 698 175 130 0
2020-08-01 21192 18911 698 82 153 0
2020-08-02 21284 18984 698 92 73 0
In [17]:
cbr_austria.plot_daily_stats()
Out[17]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f20e2eb8710>

COVID-19-Pandemie#%C3%96sterreich

Nachdem Mitte März zuerst einzelne Gemeinden unter Quarantäne gestellt wurden, verlautbarte Bundeskanzler Sebastian Kurz am 15. März eine landesweite Ausgangsbeschränkung, verbunden mit einer Einschränkung der Versammlungsfreiheit auf bis zu fünf Personen.

2020-03-15

prediction date predicted day for reaching 100 threshold predicted max growth rate steady state rate
2020-04-02 2020-04-12 13859 0.042 -
2020-04-03 2020-04-12 13864 0.036 -
2020-04-04 2020-04-12 14082 0.030 -
2020-04-05 2020-04-12 13978 0.025 -
2020-04-06 2020-04-11 13947 0.020 -
2020-04-07 2020-04-12 14033 0.017 -
2020-04-08 2020-04-12 14121 0.014 -
2020-04-09 2020-04-12 14229 0.012 -
2020-04-10 2020-04-12 14350 0.010 -
2020-04-11 2020-04-13 14488 0.009 -
2020-04-12 - - 0.012 106
2020-04-13 - - 0.012 123
2020-04-14 - - 0.011 126
2020-04-15 - - 0.010 114
2020-04-15 - - 0.009 107
2020-04-17 - - 0.009 106
2020-04-19 - - 0.007 95
2020-04-20 - - 0.007 87
2020-04-21 - - 0.006 83
2020-04-24 - - 0.005 68
2020-04-26 2020-05-01 15208 0.002 -
2020-04-27 2020-05-01 15096 0.002 -
2020-04-28 2020-05-01 15129 0.002 -
2020-04-29 - - 0.005 84
2020-04-30 - - 0.005 81
2020-05-01 - - 0.005 77
2020-05-02 - - 0.005 76
2020-05-02 - - 0.004 75
2020-05-04 - - 0.004 73
2020-05-09 - - 0.003 60
2020-05-11 - - 0.003 58
2020-05-12 - - 0.003 57
2020-05-17 - - 0.003 55
2020-05-24 - - 0.003 54
2020-05-29 - - 0.003 51
2020-06-07 - - 0.003 46
2020-06-14 - - 0.002 44
2020-06-24 - - 0.002 42
In [18]:
einwohner_deutschland = 83019213.0
einwohner_bayern      = 13076721.0
prozent_bayern        = einwohner_bayern / einwohner_deutschland
einwohner_österreich  =  8793370.0
prozent_österreich    = einwohner_österreich / einwohner_deutschland

austria_new_confirmed_threshold = (100.0 * prozent_österreich) // 1 + 1
austria_new_confirmed_threshold
Out[18]:
11.0
In [19]:
cbr_austria.fit(first_date=pd.to_datetime('2020-03-09'), new_confirmed_threshold=austria_new_confirmed_threshold)
 /home/local/cs/workspaces/covid-19-data-analysis/covid19.py:1526: UserWarning:Exception in curve_fit: Optimal parameters not found: Number of calls to function has reached maxfev = 600./ None
In [20]:
fig = plt.figure(figsize=(32,8), dpi=80, facecolor='w', edgecolor='k')
ax = plt.subplot(1,1,1)
cbr_austria.plot_with_fits(ax=ax, restriction_start_date=datetime.datetime(2020, 3, 15))
sigmoid+asymmetric+linear: seor: 60.83140122644205; growth-rate: 0.003, date:2020-09-10 00:00:00, projected value: 63.10625191231651
In [21]:
cbr_austria.fit_df0[['fit_diff']].apply(['max'])
Out[21]:
fit_diff
max 775.460289
In [22]:
cbr_austria.calculate_R_estimates()
cbr_austria.R().round(3)
 /home/local/cs/local/install/anaconda3-2020.02-Linux-x86_64/envs/py36ds/lib/python3.6/site-packages/statsmodels/tsa/base/tsa_model.py:162: ValueWarning:No frequency information was provided, so inferred frequency D will be used.
Out[22]:
fit_R gp_R kf_R ll_R mean_R
index
2020-07-31 1.0 1.145 1.254 1.157 1.101
In [23]:
fig = plt.figure(figsize=(32,8), dpi=80, facecolor='w', edgecolor='k')
ax = plt.subplot(1,1,1)
cbr_austria.plot_R(ax=ax) # , plot_start_date='2020-03-10'
Out[23]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f20e47afcf8>

COVID-19-Pandemie#Dänemark

Dänemark hat besonders früh mit strikten Maßnahmen auf die Corona-Krise reagiert, unter anderem sind seit dem 14. März die Grenzen für Ausländer ohne triftigen Einreisegrund geschlossen.

2020-03-14

In [24]:
cbr_denmark = covid19.CasesByRegion('Denmark')
cbr_denmark.tail()
Out[24]:
confirmed recovered death new_confirmed new_recovered new_death
2020-07-29 13868 12686 614 57 34 1
2020-07-30 13964 12727 615 96 41 1
2020-07-31 14028 12780 615 64 53 0
2020-08-01 14028 12780 615 0 0 0
2020-08-02 14028 12783 615 0 3 0
In [25]:
cbr_denmark.plot_daily_stats()
Out[25]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f20e479bc18>
In [26]:
population_denmark  =  5822763.0
percent_denmark     = population_denmark / einwohner_deutschland

denmark_new_confirmed_threshold = (100.0 * percent_denmark) // 1 + 1
print(denmark_new_confirmed_threshold)

# first_date=pd.to_datetime('2020-03-09')
# first_date=pd.to_datetime('2020-03-14')
cbr_denmark.fit(first_date=pd.to_datetime('2020-03-14'), new_confirmed_threshold=denmark_new_confirmed_threshold)
fig = plt.figure(figsize=(32,8), dpi=80, facecolor='w', edgecolor='k')
ax = plt.subplot(1,1,1)
cbr_denmark.plot_with_fits(ax=ax, restriction_start_date=datetime.datetime(2020, 3, 14))
8.0
 /home/local/cs/workspaces/covid-19-data-analysis/covid19.py:1526: UserWarning:Exception in curve_fit: Optimal parameters not found: Number of calls to function has reached maxfev = 600./ None
sigmoid+asymmetric+linear: seor: 35.20632588881581; growth-rate: 0.002, date:2020-09-10 00:00:00, projected value: 34.14732474344837
In [27]:
cbr_denmark.fit_df0[['fit_diff']].apply(['max'])
Out[27]:
fit_diff
max 263.998938
In [28]:
cbr_denmark.calculate_R_estimates()
cbr_denmark.R().round(3)
 /home/local/cs/local/install/anaconda3-2020.02-Linux-x86_64/envs/py36ds/lib/python3.6/site-packages/statsmodels/tsa/base/tsa_model.py:162: ValueWarning:No frequency information was provided, so inferred frequency D will be used.
Out[28]:
fit_R gp_R kf_R ll_R mean_R
2020-07-31 0.997 1.37 1.525 1.415 1.261
In [29]:
fig = plt.figure(figsize=(32,8), dpi=80, facecolor='w', edgecolor='k')
ax = plt.subplot(1,1,1)
cbr_denmark.plot_R(ax=ax) # , plot_start_date='2020-03-10'
Out[29]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f20e1c18cc0>

There are several data issues since 2020-03-12/2020-03-13 in the input data as pointed out here: Italy has the same number of cases today as they did yesterday.

Also trying to get the raw numbers that Coronavirus-Monitor is using for Germany from @datentaeterin. These numbers seem to be more up-to-date than all the other data-sources.

In [30]:
df = covid19.get_italy_df()
cbr_italy = covid19.CasesByRegion('Italy', df=df)
cbr_italy.tail()
Out[30]:
confirmed recovered death new_confirmed new_recovered new_death
data
2020-07-29 246776 199031 35129 288 275 6
2020-07-30 247158 199796 35132 382 765 3
2020-07-31 247537 199974 35141 379 178 9
2020-08-01 247832 200229 35146 295 255 5
2020-08-02 248070 200460 35154 238 231 8
In [31]:
cbr_italy.plot_daily_stats()
Out[31]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f20e1baac88>
In [32]:
cbr_italy.fit(first_date=pd.to_datetime('2020-02-21'))
 /home/local/cs/workspaces/covid-19-data-analysis/covid19.py:1526: UserWarning:Exception in curve_fit: Optimal parameters not found: Number of calls to function has reached maxfev = 600./ None
In [33]:
fig = plt.figure(figsize=(32,8), dpi=80, facecolor='w', edgecolor='k')
ax = plt.subplot(1,1,1)
cbr_italy.plot_with_fits(ax=ax, restriction_start_date=datetime.datetime(2020, 3, 9))
sigmoid+asymmetric+linear: seor: 336.7053473347178; growth-rate: 0.001, date:2020-09-10 00:00:00, projected value: 156.94223808754975
In [34]:
cbr_italy.fit_df0[['fit_diff']].apply(['max'])
Out[34]:
fit_diff
max 5376.580995
In [35]:
cbr_italy.calculate_R_estimates()
cbr_italy.R().round(3)
 /home/local/cs/local/install/anaconda3-2020.02-Linux-x86_64/envs/py36ds/lib/python3.6/site-packages/statsmodels/tsa/base/tsa_model.py:162: ValueWarning:No frequency information was provided, so inferred frequency D will be used.
Out[35]:
fit_R gp_R kf_R ll_R mean_R
data
2020-07-31 0.976 1.233 1.461 1.241 1.15
In [36]:
fig = plt.figure(figsize=(32,8), dpi=80, facecolor='w', edgecolor='k')
ax = plt.subplot(1,1,1)
cbr_italy.plot_R(ax=ax) # , plot_start_date='2020-03-10'
Out[36]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f20dc6656a0>
In [37]:
df = covid19.get_spain_df()
cbr_spain = covid19.CasesByRegion('Spain', df=df)
cbr_spain.tail()
read csv
Out[37]:
confirmed recovered death new_confirmed new_recovered new_death
index
2020-07-27 278782 150376 28434 6361 0 2
2020-07-28 280610 150376 28436 1828 0 2
2020-07-29 282641 150376 28441 2031 0 5
2020-07-30 285430 150376 28443 2789 0 2
2020-07-31 288522 150376 28445 3092 0 2
In [38]:
cbr_spain.plot_daily_stats()
Out[38]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f20dc5e5da0>