Visualisation des données par pays

Ces séries représentent celles des décès. Le nombre de cas positifs est différent selon les pays de par leur capacité de tests et au nombreux cas asymptomatiques.

Récupération des données

Les décès.

from aftercovid.preprocess import ts_normalise_negative_values
import matplotlib.pyplot as plt
import pandas

url = ("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/"
       "master/csse_covid_19_data/"
       "csse_covid_19_time_series/time_series_covid19_deaths_global.csv")
df = pandas.read_csv(url)
df.head()
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 ... 9/7/21 9/8/21 9/9/21 9/10/21 9/11/21 9/12/21 9/13/21 9/14/21 9/15/21 9/16/21 9/17/21 9/18/21 9/19/21 9/20/21 9/21/21 9/22/21 9/23/21 9/24/21 9/25/21 9/26/21 9/27/21 9/28/21 9/29/21 9/30/21 10/1/21 10/2/21 10/3/21 10/4/21 10/5/21 10/6/21 10/7/21 10/8/21 10/9/21 10/10/21 10/11/21 10/12/21 10/13/21 10/14/21 10/15/21 10/16/21
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 ... 7144 7151 7157 7164 7167 7167 7169 7171 7174 7183 7186 7186 7186 7199 7199 7199 7199 7199 7199 7199 7200 7201 7204 7204 7206 7206 7206 7212 7214 7220 7221 7221 7221 7225 7228 7230 7234 7238 7238 7238
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 ... 2523 2528 2531 2535 2539 2543 2548 2553 2557 2563 2569 2574 2580 2587 2594 2601 2609 2619 2629 2640 2653 2668 2685 2698 2705 2710 2713 2713 2725 2734 2746 2753 2759 2768 2777 2783 2788 2797 2807 2810
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 ... 5471 5489 5519 5539 5558 5578 5596 5614 5630 5651 5670 5681 5694 5709 5725 5739 5748 5758 5767 5777 5786 5797 5805 5812 5815 5819 5822 5826 5831 5838 5843 5846 5850 5853 5855 5859 5862 5864 5867 5870
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 ... 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130
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 ... 1299 1309 1313 1322 1327 1339 1345 1358 1360 1371 1378 1388 1388 1409 1414 1434 1460 1471 1487 1501 1513 1526 1537 1537 1567 1574 1577 1577 1587 1598 1603 1613 1618 1622 1629 1642 1650 1653 1660 1662

5 rows × 638 columns



Les cas positifs.

url = ("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/"
       "master/csse_covid_19_data/"
       "csse_covid_19_time_series/time_series_covid19_confirmed_global.csv")
dfpos = pandas.read_csv(url)
dfpos.head()
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 ... 9/7/21 9/8/21 9/9/21 9/10/21 9/11/21 9/12/21 9/13/21 9/14/21 9/15/21 9/16/21 9/17/21 9/18/21 9/19/21 9/20/21 9/21/21 9/22/21 9/23/21 9/24/21 9/25/21 9/26/21 9/27/21 9/28/21 9/29/21 9/30/21 10/1/21 10/2/21 10/3/21 10/4/21 10/5/21 10/6/21 10/7/21 10/8/21 10/9/21 10/10/21 10/11/21 10/12/21 10/13/21 10/14/21 10/15/21 10/16/21
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 5 5 5 ... 153626 153736 153840 153962 153982 153990 154094 154180 154283 154361 154487 154487 154487 154585 154712 154757 154800 154960 154960 154960 155072 155093 155128 155174 155191 155191 155191 155287 155309 155380 155429 155448 155466 155508 155540 155599 155627 155682 155688 155739
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 ... 152239 153318 154316 155293 156162 157026 157436 158431 159423 160365 161324 162173 162953 163404 164276 165096 165864 166690 167354 167893 168188 168782 169462 170131 170778 171327 171794 171794 172618 173190 173723 174168 174643 174968 175163 175664 176172 176667 177108 177536
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 ... 198645 198962 199275 199560 199822 200068 200301 200528 200770 200989 201224 201425 201600 201766 201948 202122 202283 202449 202574 202722 202877 203045 203198 203359 203517 203657 203789 203915 204046 204171 204276 204388 204490 204597 204695 204790 204900 205005 205106 205199
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 ... 15070 15070 15078 15083 15083 15083 15096 15099 15108 15113 15124 15124 15124 15140 15140 15153 15156 15167 15167 15167 15189 15192 15209 15222 15222 15222 15222 15267 15271 15284 15288 15291 15291 15291 15307 15307 15314 15326 15338 15338
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 ... 49114 49349 49628 49943 50348 50446 50738 51047 51407 51827 52208 52307 52307 52644 52968 53387 53840 54280 54795 55121 55583 56040 56583 56583 58076 58603 58943 58943 59895 60448 60803 61023 61245 61378 61580 61794 62143 62385 62606 62789

5 rows × 638 columns



Tous les pays

print(" --- ".join(sorted(set(df['Country/Region']))))

Out:

Afghanistan --- Albania --- Algeria --- Andorra --- Angola --- Antigua and Barbuda --- Argentina --- Armenia --- Australia --- Austria --- Azerbaijan --- Bahamas --- Bahrain --- Bangladesh --- Barbados --- Belarus --- Belgium --- Belize --- Benin --- Bhutan --- Bolivia --- Bosnia and Herzegovina --- Botswana --- Brazil --- Brunei --- Bulgaria --- Burkina Faso --- Burma --- Burundi --- Cabo Verde --- Cambodia --- Cameroon --- Canada --- Central African Republic --- Chad --- Chile --- China --- Colombia --- Comoros --- Congo (Brazzaville) --- Congo (Kinshasa) --- Costa Rica --- Cote d'Ivoire --- Croatia --- Cuba --- Cyprus --- Czechia --- Denmark --- Diamond Princess --- Djibouti --- Dominica --- Dominican Republic --- Ecuador --- Egypt --- El Salvador --- Equatorial Guinea --- Eritrea --- Estonia --- Eswatini --- Ethiopia --- Fiji --- Finland --- France --- Gabon --- Gambia --- Georgia --- Germany --- Ghana --- Greece --- Grenada --- Guatemala --- Guinea --- Guinea-Bissau --- Guyana --- Haiti --- Holy See --- Honduras --- Hungary --- Iceland --- India --- Indonesia --- Iran --- Iraq --- Ireland --- Israel --- Italy --- Jamaica --- Japan --- Jordan --- Kazakhstan --- Kenya --- Kiribati --- Korea, South --- Kosovo --- Kuwait --- Kyrgyzstan --- Laos --- Latvia --- Lebanon --- Lesotho --- Liberia --- Libya --- Liechtenstein --- Lithuania --- Luxembourg --- MS Zaandam --- Madagascar --- Malawi --- Malaysia --- Maldives --- Mali --- Malta --- Marshall Islands --- Mauritania --- Mauritius --- Mexico --- Micronesia --- Moldova --- Monaco --- Mongolia --- Montenegro --- Morocco --- Mozambique --- Namibia --- Nepal --- Netherlands --- New Zealand --- Nicaragua --- Niger --- Nigeria --- North Macedonia --- Norway --- Oman --- Pakistan --- Palau --- Panama --- Papua New Guinea --- Paraguay --- Peru --- Philippines --- Poland --- Portugal --- Qatar --- Romania --- Russia --- Rwanda --- Saint Kitts and Nevis --- Saint Lucia --- Saint Vincent and the Grenadines --- Samoa --- San Marino --- Sao Tome and Principe --- Saudi Arabia --- Senegal --- Serbia --- Seychelles --- Sierra Leone --- Singapore --- Slovakia --- Slovenia --- Solomon Islands --- Somalia --- South Africa --- South Sudan --- Spain --- Sri Lanka --- Sudan --- Summer Olympics 2020 --- Suriname --- Sweden --- Switzerland --- Syria --- Taiwan* --- Tajikistan --- Tanzania --- Thailand --- Timor-Leste --- Togo --- Trinidad and Tobago --- Tunisia --- Turkey --- US --- Uganda --- Ukraine --- United Arab Emirates --- United Kingdom --- Uruguay --- Uzbekistan --- Vanuatu --- Venezuela --- Vietnam --- West Bank and Gaza --- Yemen --- Zambia --- Zimbabwe

On en sélectionne quelques-uns.

keep = ['France', 'Belgium', 'Italy', 'United Kingdom',
        'US', 'Spain', 'Germany']
eur = df[df['Country/Region'].isin(keep) & df['Province/State'].isna()]
eurpos = dfpos[dfpos['Country/Region'].isin(keep)
               & dfpos['Province/State'].isna()]
eur
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 ... 9/7/21 9/8/21 9/9/21 9/10/21 9/11/21 9/12/21 9/13/21 9/14/21 9/15/21 9/16/21 9/17/21 9/18/21 9/19/21 9/20/21 9/21/21 9/22/21 9/23/21 9/24/21 9/25/21 9/26/21 9/27/21 9/28/21 9/29/21 9/30/21 10/1/21 10/2/21 10/3/21 10/4/21 10/5/21 10/6/21 10/7/21 10/8/21 10/9/21 10/10/21 10/11/21 10/12/21 10/13/21 10/14/21 10/15/21 10/16/21
23 NaN Belgium 50.833300 4.469936 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 ... 25428 25442 25447 25454 25454 25454 25473 25477 25486 25494 25497 25497 25497 25517 25524 25533 25543 25554 25554 25554 25568 25581 25595 25602 25612 25612 25612 25632 25640 25649 25665 25675 25675 25675 25695 25713 25726 25732 25747 25747
130 NaN France 46.227600 2.213700 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 2 ... 113385 113385 113475 113569 113615 113644 113711 113805 113805 113836 113923 113965 113993 113993 114097 114148 114209 114262 114262 114276 114347 114394 114430 114491 114538 114568 114577 114620 114660 114679 114712 114750 114765 114773 114808 114860 114860 114887 114921 114936
134 NaN Germany 51.165691 10.451526 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 ... 92463 92463 92559 92604 92612 92625 92694 92776 92843 92906 92928 92964 92977 93058 93129 93243 93310 93370 93398 93409 93509 93576 93643 93715 93781 93791 93798 93887 93963 94031 94117 94182 94206 94213 94308 94393 94407 94530 94605 94622
153 NaN Italy 41.871940 12.567380 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 3 7 10 12 ... 129638 129707 129766 129828 129885 129919 129955 130027 130100 130167 130233 130284 130310 130354 130421 130488 130551 130603 130653 130697 130742 130807 130870 130921 130973 130998 131031 131068 131118 131157 131198 131228 131274 131301 131335 131384 131421 131461 131503 131517
237 NaN Spain 40.463667 -3.749220 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 ... 85066 85147 85218 85290 85290 85290 85393 85548 85638 85739 85783 85783 85783 85901 85983 86085 86185 86229 86229 86229 86298 86358 86397 86415 86463 86463 86463 86527 86621 86678 86701 86778 86778 86778 86827 86827 86869 86917 86974 86974
254 NaN US 40.000000 -100.000000 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 ... 651886 654089 657363 659735 660495 660824 663034 664838 667577 671045 673457 674331 674685 677038 679291 682114 685324 687868 688566 688889 691307 693364 695916 698662 700790 701451 701704 703819 705553 708110 710502 712339 712618 712873 714055 716471 719558 721563 723754 724153
269 NaN United Kingdom 55.378100 -3.436000 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 ... 133483 133674 133841 133988 134144 134200 134261 134446 134647 134805 134983 135147 135203 135252 135455 135621 135803 135983 136105 136168 136208 136375 136525 136662 136789 136910 136953 136986 137152 137295 137417 137541 137697 137735 137763 137944 138080 138237 138379 138527

7 rows × 638 columns



En colonne.

cols = list(eur['Country/Region'])
tf = eur.T.iloc[4:]
tf.columns = cols
tf.tail()
Belgium France Germany Italy Spain US United Kingdom
10/12/21 25713 114860 94393 131384 86827 716471 137944
10/13/21 25726 114860 94407 131421 86869 719558 138080
10/14/21 25732 114887 94530 131461 86917 721563 138237
10/15/21 25747 114921 94605 131503 86974 723754 138379
10/16/21 25747 114936 94622 131517 86974 724153 138527


Les cas positifs.

colspos = list(eurpos['Country/Region'])
tfpos = eurpos.T.iloc[4:]
tfpos.columns = colspos
tfpos.tail()
Belgium France Germany Italy Spain US United Kingdom
10/12/21 1269002 6890619 4331274 4704318 4977448 44562693 8231437
10/13/21 1272669 6890619 4343591 4707087 4980206 44684150 8272883
10/14/21 1276221 6899839 4355169 4709753 4982138 44767906 8317439
10/15/21 1279869 6905628 4366833 4712482 4984386 44884598 8361651
10/16/21 1279869 6910527 4375253 4715464 4984386 44916423 8404469


Nombre de décès par pays

fig, ax = plt.subplots(1, 3, figsize=(14, 6))
tf.plot(logy=False, lw=3, title="Nombre de décès COVID", ax=ax[0])
tf.plot(logy=True, lw=3, ax=ax[1])
tf.tail(n=60).plot(logy=True, lw=3, ax=ax[2])
Nombre de décès COVID

Nombre de décès par pays par jour

fig, ax = plt.subplots(1, 3, figsize=(14, 6))
dtf = tfpos.diff()
dtf.plot(logy=False, lw=3, title="Nombre de décès COVID\npar jour", ax=ax[0])
dtf.plot(logy=True, lw=3, ax=ax[1])
dtf.tail(n=60).plot(logy=True, lw=3, ax=ax[2])
Nombre de décès COVID par jour

Cas positifs par pays

fig, ax = plt.subplots(1, 3, figsize=(14, 6))
tfpos.plot(logy=False, lw=3, title="Nombre de cas positifs COVID", ax=ax[0])
tfpos.plot(logy=True, lw=3, ax=ax[1])
tfpos.tail(
    n=60).plot(
        logy=True,
        lw=3,
        title="Nombre de cas positifs COVID",
    ax=ax[2])
Nombre de cas positifs COVID, Nombre de cas positifs COVID

Cas positifs par pays par jour

fig, ax = plt.subplots(1, 3, figsize=(14, 6))
dtfpos = tfpos.diff()
dtfpos.plot(
    logy=False, lw=3, title="Nombre de cas positifs COVID\npar jour",
    ax=ax[0])
dtfpos.plot(logy=True, lw=3, ax=ax[1])
tfpos.tail(
    n=60).plot(
        logy=True,
        lw=3,
        title="Nombre de cas positifs COVID",
    ax=ax[2])
Nombre de cas positifs COVID par jour, Nombre de cas positifs COVID

On lisse sur une semaine.

tdroll = tf.rolling(7, center=False).mean()
tdroll.tail()
Belgium France Germany Italy Spain US United Kingdom
10/12/21 25678.142857 114763.857143 94207.142857 131268.142857 86766.714286 712424.000000 137627.428571
10/13/21 25689.142857 114789.714286 94260.857143 131305.857143 86794.000000 714059.428571 137739.571429
10/14/21 25698.714286 114814.714286 94319.857143 131343.428571 86824.857143 715639.571429 137856.714286
10/15/21 25709.000000 114839.142857 94380.285714 131382.714286 86852.857143 717270.285714 137976.428571
10/16/21 25719.285714 114863.571429 94439.714286 131417.428571 86880.857143 718918.142857 138095.000000


Séries lissées.

fig, ax = plt.subplots(1, 3, figsize=(14, 6))
tdroll.plot(logy=False, lw=3, ax=ax[0],
            title="Nombre de décès COVID lissé sur une semaine")
tdroll.plot(logy=True, lw=3, ax=ax[1],
            title="Nombre de décès COVID lissé sur une semaine")
tdroll.tail(60).plot(logy=True, lw=3, ax=ax[2],
                     title="Nombre de décès COVID lissé sur une semaine")
Nombre de décès COVID lissé sur une semaine, Nombre de décès COVID lissé sur une semaine, Nombre de décès COVID lissé sur une semaine
tdposroll = tfpos.rolling(7, center=False).mean()
tdposroll.plot(logy=False, lw=3, ax=ax[0],
               title="Nombre de cas positifs COVID lissé sur une semaine")
tdposroll.plot(logy=True, lw=3, ax=ax[1],
               title="Nombre de cas positifs COVID lissé sur une semaine")
tdposroll.tail(60).plot(
    logy=True,
    lw=3,
    ax=ax[2],
    title="Nombre de cas positifs COVID lissé sur une semaine")

Séries décalées

On ne s’intéresse qu’aux séries de décès. Les séries des cas positifs sont plutôt des estimateurs imparfaits. On compare les séries en prenant comme point de départ la date qui correspond au 20ième décès.

def find_day(ts, th):
    tsth = ts[ts >= th]
    return tsth.index[0]


def delag(ts, th=21, begin=-2):
    index = find_day(ts, th)
    loc = ts.index.get_loc(index)
    values = ts.reset_index(drop=True)
    return values[loc + begin:].reset_index(drop=True)


print(find_day(tdroll['France'], 25), delag(tdroll['France'])[:15])

Out:

3/12/20 0      12.000000
1      16.142857
2      22.428571
3      28.285714
4      38.285714
5      49.000000
6      59.285714
7      76.857143
8      93.285714
9     107.571429
10    135.428571
11    188.428571
12    255.714286
13    339.000000
14    440.714286
Name: France, dtype: float64

On décale pour chaque pays.

data = {}
for c in tdroll.columns:
    data[c] = delag(tdroll[c], 21)
dl = pandas.DataFrame(data)
dl.head()
Belgium France Germany Italy Spain US United Kingdom
0 8.714286 12.000000 14.142857 14.142857 9.428571 14.857143 9.571429
1 13.571429 16.142857 20.000000 18.571429 14.285714 17.857143 15.428571
2 22.571429 22.428571 28.571429 25.000000 21.714286 21.000000 24.285714
3 32.714286 28.285714 39.285714 34.857143 29.142857 25.428571 35.000000
4 44.571429 38.285714 51.142857 48.428571 47.428571 30.714286 50.571429


Belgium France Germany Italy Spain US United Kingdom
591 NaN NaN NaN 131268.142857 NaN NaN NaN
592 NaN NaN NaN 131305.857143 NaN NaN NaN
593 NaN NaN NaN 131343.428571 NaN NaN NaN
594 NaN NaN NaN 131382.714286 NaN NaN NaN
595 NaN NaN NaN 131417.428571 NaN NaN NaN


Graphes.

fig, ax = plt.subplots(1, 3, figsize=(14, 8))
dl.plot(logy=False, lw=3, ax=ax[0])
dl.plot(logy=True, lw=3, ax=ax[1])
dl.tail(60).plot(logy=True, lw=3, ax=ax[2])
ax[0].set_title(
    "Nombre de décès après N jours\ndepuis le début de l'épidémie")
Nombre de décès après N jours depuis le début de l'épidémie

Le fléchissement indique que la propagation n’est plus logarithmique après la fin du confinement.

Séries différentielles

C’est surtout celle-ci qu’on regarde pour contrôler l’évolution de l’épidémie. Certaines valeurs sont négatives laissant penser que la façon de reporter les décès a évolué au cours du temps. C’est problématique lorsqu’on souhaite caler un modèle.

neg = tf.diff()
neg[neg['Spain'] < 0]
Belgium France Germany Italy Spain US United Kingdom
5/25/20 32 89 26 92 -1918 598 104
8/12/20 15 17 5 10 -2 1504 20


Et pour la France.

neg[neg['France'] < 0]
Belgium France Germany Italy Spain US United Kingdom
5/19/20 28 -217 78 162 69 1452 500
5/24/20 43 -82 22 50 74 640 379
7/21/20 0 -14 5 15 2 1085 25
9/4/20 2 -22 5 11 184 957 10
10/25/20 73 -21 27 128 0 461 151
11/4/20 205 -38 232 352 1623 1107 492
2/4/21 44 -4 858 421 432 3747 915
7/14/21 0 -6 31 23 10 335 49
8/28/21 0 -46 11 54 0 571 133


On continue néanmoins mais en corrigeant ces séries qu’il n’y ait plus aucune valeur négative.

tfdiff = ts_normalise_negative_values(tf.diff()).rolling(
    7, center=False, win_type='triang').mean()
fig, ax = plt.subplots(1, 3, figsize=(14, 6))
tfdiff.plot(
    logy=False, lw=3, ax=ax[0],
    title="Nombre de décès COVID par jour lissé par semaine")
ax[0].set_ylim(0)
tfdiff.plot(
    logy=True, lw=3, ax=ax[1],
    title="Nombre de décès COVID par jour lissé par semaine")
tfdiff.tail(60).plot(
    logy=True, lw=3, ax=ax[2],
    title="Nombre de décès COVID par jour lissé par semaine")
Nombre de décès COVID par jour lissé par semaine, Nombre de décès COVID par jour lissé par semaine, Nombre de décès COVID par jour lissé par semaine

Les mêmes chiffres en recalant les séries au jour du 20ième décès.

dldiff = ts_normalise_negative_values(dl.diff()).rolling(
    7, center=False, win_type='triang').mean()

print(",".join(map(str, dl.diff()['Spain'])))

Out:

somewhereaftercovid_39_std/aftercovid/aftercovid/preprocess/ts.py:96: RuntimeWarning: invalid value encountered in true_divide
  res[d + 1:-d] = (ret[n:] - ret[:-n]) / (wet[n:] - wet[:-n])
somewhereaftercovid_39_std/aftercovid/aftercovid/preprocess/ts.py:99: RuntimeWarning: invalid value encountered in true_divide
  res[-i - 1] = numpy.divide(ret[-1] - ret[-(i + d) - 1],
nan,4.857142857142858,7.428571428571429,7.428571428571427,18.28571428571429,26.42857142857143,38.85714285714285,44.857142857142875,71.14285714285714,81.28571428571428,110.71428571428572,129.99999999999994,168.57142857142867,211.85714285714278,281.2857142857142,325.0,432.0,505.0000000000002,585.0,658.1428571428569,718.7142857142862,772.1428571428569,808.0,820.0,854.7142857142853,865.7142857142862,852.1428571428569,834.0,803.5714285714294,797.2857142857138,772.1428571428569,728.4285714285706,697.5714285714294,665.5714285714294,652.5714285714275,630.7142857142862,572.9999999999982,559.4285714285725,552.5714285714275,560.1428571428587,491.0,463.42857142857247,442.28571428571377,460.8571428571413,429.85714285714494,406.0,360.28571428571377,408.42857142857247,391.0,381.28571428571377,362.8571428571413,365.42857142857247,340.8571428571413,288.42857142857247,314.0,296.28571428571377,272.42857142857247,255.8571428571413,226.0,218.1428571428587,250.8571428571413,196.85714285714494,193.8571428571413,188.0,186.71428571428623,178.1428571428587,178.7142857142826,165.71428571428623,155.0,134.57142857143117,137.8571428571413,122.57142857142753,112.0,88.42857142857247,167.0,159.28571428571377,169.85714285714494,-125.0,-94.42857142857247,-110.1428571428587,-117.28571428571377,-215.28571428571377,-221.8571428571413,-232.1428571428587,41.8571428571413,1.428571428572468,1.571428571427532,2.0,1.857142857144936,1.428571428572468,1.285714285713766,1.285714285713766,1.285714285713766,1.142857142858702,0.42857142856883,0.285714285713766,0.142857142858702,0.0,0.0,0.0,0.0,0.0,168.42857142857247,169.42857142856883,169.57142857143117,169.71428571428623,169.8571428571413,170.1428571428587,170.57142857142753,3.285714285713766,2.714285714286234,2.857142857141298,3.142857142858702,4.285714285713766,5.285714285713766,5.428571428572468,6.714285714286234,6.285714285713766,6.0,6.0,5.285714285713766,4.571428571427532,4.714285714286234,2.571428571427532,2.57142857143117,2.571428571427532,2.571428571427532,2.428571428572468,2.428571428572468,2.142857142855064,2.428571428572468,2.428571428572468,2.42857142856883,2.285714285717404,2.142857142855064,1.857142857144936,1.857142857141298,1.714285714286234,1.714285714286234,1.714285714286234,1.714285714282596,1.714285714286234,2.142857142858702,2.0,1.857142857141298,1.857142857144936,1.857142857141298,5.428571428572468,8.857142857141298,8.285714285713766,8.142857142858702,8.285714285713766,8.285714285713766,8.285714285713766,14.857142857144936,11.857142857141298,11.428571428572468,15.0,16.285714285713766,16.285714285713766,16.285714285713766,10.0,12.714285714286234,31.142857142858702,29.714285714286234,31.571428571427532,31.571428571427532,31.57142857143117,32.285714285713766,36.285714285713766,24.857142857141298,26.142857142858702,24.714285714286234,24.714285714286234,24.714285714282596,31.714285714286234,32.57142857143117,31.857142857141298,34.0,58.1428571428587,58.142857142855064,58.1428571428587,60.285714285713766,63.142857142855064,62.0,66.42857142857247,47.0,47.0,47.0,47.42857142857247,58.57142857142753,87.85714285714494,100.8571428571413,106.8571428571413,106.85714285714494,106.8571428571413,116.42857142857247,128.57142857142753,113.0,101.85714285714494,105.28571428571377,105.28571428571377,105.28571428571377,106.85714285714494,72.42857142856883,108.1428571428587,122.14285714285506,122.0,122.0,122.0,116.2857142857174,153.57142857142753,110.14285714285506,102.1428571428587,120.42857142857247,120.42857142856883,120.42857142857247,128.42857142856883,102.57142857143481,121.57142857142753,123.57142857142753,120.85714285714494,120.85714285713766,120.85714285714494,124.0,143.7142857142826,136.14285714286234,138.28571428571013,139.57142857142753,139.5714285714348,139.57142857142753,148.42857142857247,155.4285714285652,157.14285714286234,159.7142857142826,160.85714285714494,160.85714285714494,160.85714285713766,175.14285714286234,171.0,378.85714285713766,406.7142857142899,422.14285714285506,422.14285714285506,422.14285714286234,441.14285714285506,407.14285714285506,283.85714285714494,282.14285714285506,276.57142857142753,276.57142857142753,276.5714285714348,272.57142857142753,334.7142857142826,276.2857142857174,261.42857142857247,264.2857142857101,264.2857142857174,264.2857142857101,268.2857142857174,282.85714285714494,285.4285714285652,297.5714285714348,292.7142857142826,292.7142857142826,292.7142857142899,276.85714285714494,263.2857142857101,249.57142857142753,237.71428571428987,226.28571428571013,226.2857142857174,226.28571428571013,225.2857142857174,162.14285714285506,176.42857142857247,186.57142857142753,196.0,196.0,196.0,195.2857142857174,250.7142857142826,225.2857142857174,204.7142857142826,186.0,186.0,186.0,178.14285714286234,159.85714285713766,157.42857142857247,149.57142857142753,128.2857142857174,128.28571428571013,128.2857142857174,123.14285714285506,131.71428571428987,141.57142857142753,144.7142857142826,144.71428571428987,144.7142857142826,144.71428571428987,136.57142857142753,141.14285714285506,105.85714285714494,119.7142857142826,148.14285714285506,148.14285714286234,148.14285714285506,171.0,179.0,206.85714285714494,200.57142857142753,205.7142857142826,205.71428571428987,205.7142857142826,213.42857142857247,212.85714285714494,251.28571428571013,280.2857142857174,303.85714285714494,303.85714285713766,303.85714285714494,348.42857142857247,374.42857142857247,379.14285714285506,395.0,411.14285714285506,411.14285714286234,411.14285714285506,410.42857142857247,430.14285714285506,439.85714285714494,428.0,438.14285714285506,438.14285714285506,438.14285714286234,459.14285714285506,465.14285714285506,476.2857142857174,487.85714285713766,480.14285714286234,480.14285714285506,480.14285714285506,450.57142857142753,416.85714285714494,373.14285714285506,355.2857142857174,336.2857142857101,336.2857142857247,336.2857142857101,312.4285714285652,300.0,307.42857142857974,301.2857142857101,291.5714285714348,291.57142857142026,291.5714285714348,281.85714285714494,246.0,254.14285714285506,241.14285714285506,285.14285714285506,285.14285714285506,285.14285714285506,261.0,275.14285714285506,244.85714285714494,226.28571428572468,160.0,160.0,160.0,141.14285714285506,119.71428571427532,118.85714285714494,117.85714285714494,93.14285714285506,93.14285714285506,93.14285714286962,159.85714285713038,168.42857142857974,135.85714285714494,215.71428571427532,300.0,300.0,300.0,236.5714285714348,223.0,245.0,160.14285714285506,75.85714285714494,98.28571428571013,98.28571428572468,83.42857142856519,86.57142857143481,82.57142857142026,91.14285714285506,112.42857142857974,90.0,90.0,106.0,102.0,102.71428571427532,100.42857142857974,93.28571428571013,93.28571428571013,93.28571428572468,82.42857142856519,68.14285714285506,86.85714285714494,87.71428571428987,87.14285714285506,87.14285714285506,87.14285714285506,90.85714285714494,107.57142857143481,82.71428571427532,83.42857142857974,89.28571428571013,89.28571428571013,89.28571428572468,79.28571428571013,77.71428571428987,89.0,92.28571428571013,82.28571428571013,82.28571428572468,82.28571428571013,86.0,100.14285714285506,91.71428571428987,79.28571428571013,78.14285714285506,78.14285714285506,78.14285714285506,76.71428571428987,57.428571428579744,51.42857142856519,45.71428571428987,40.142857142855064,40.142857142855064,40.142857142855064,39.857142857144936,42.71428571428987,41.0,41.0,40.71428571427532,40.71428571428987,40.71428571428987,34.571428571420256,26.0,27.714285714289872,23.0,41.428571428579744,41.571428571420256,41.57142857143481,40.42857142856519,46.57142857143481,40.42857142856519,59.428571428579744,43.71428571427532,43.57142857143481,43.571428571420256,40.142857142869616,38.571428571420256,40.428571428579744,24.142857142855064,21.571428571420256,21.571428571434808,21.571428571420256,24.571428571434808,20.0,19.0,18.857142857144936,18.142857142855064,18.142857142855064,18.142857142855064,14.28571428572468,15.71428571427532,18.142857142855064,16.714285714289872,18.857142857144936,18.857142857144936,18.857142857144936,20.71428571427532,17.571428571434808,13.428571428565192,16.28571428572468,13.142857142855064,13.142857142855064,13.142857142855064,12.285714285710128,11.571428571434808,10.571428571434808,12.428571428565192,13.285714285710128,13.28571428572468,13.285714285710128,14.142857142855064,16.428571428565192,17.571428571434808,15.714285714289872,17.857142857144936,17.857142857130384,17.857142857144936,21.28571428572468,25.0,32.857142857130384,35.428571428579744,37.857142857144936,37.857142857144936,37.857142857130384,53.57142857143481,64.28571428571013,64.0,69.85714285714494,74.28571428571013,74.28571428572468,74.28571428571013,68.85714285714494,64.85714285714494,68.0,68.0,66.28571428571013,66.28571428571013,66.28571428572468,67.14285714285506,73.14285714285506,80.42857142856519,85.28571428572468,95.14285714285506,95.14285714285506,95.14285714285506,106.0,112.57142857143481,115.28571428571013,122.42857142856519,123.42857142857974,123.42857142856519,123.42857142857974,115.57142857142026,116.14285714285506,111.71428571428987,111.28571428571013,113.57142857143481,113.57142857142026,113.57142857143481,111.71428571428987,103.71428571427532,96.42857142857974,82.57142857142026,70.71428571428987,70.71428571428987,70.71428571428987,66.42857142856519,68.85714285714494,70.14285714285506,74.42857142856519,70.42857142857974,70.42857142856519,70.42857142857974,72.57142857142026,62.142857142855064,63.857142857144936,63.71428571428987,63.71428571428987,63.71428571427532,63.71428571428987,56.71428571428987,53.571428571420256,44.57142857143481,32.857142857144936,33.42857142856519,33.428571428579744,33.42857142856519,32.71428571428987,37.571428571420256,40.142857142869616,40.857142857130384,45.0,45.0,45.0,42.857142857144936,29.428571428579744,27.285714285710128,30.857142857144936,28.0,28.0,nan,nan,nan,nan,nan,nan,nan,nan,nan
fig, ax = plt.subplots(1, 3, figsize=(14, 8))
dldiff.plot(logy=False, lw=3, ax=ax[0])
dldiff.plot(logy=True, lw=3, ax=ax[1])
dldiff.tail(60).plot(logy=True, lw=3, ax=ax[2])
ax[0].set_ylim(0)
ax[0].set_title(
    "Nombre de décès lissé sur 7 jours\npar jour après N jours"
    "\ndepuis le début de l'épidémie")
Nombre de décès lissé sur 7 jours par jour après N jours depuis le début de l'épidémie
tfdiff = ts_normalise_negative_values(tf.diff(), extreme=2).rolling(
    7, center=False, win_type='triang').mean()


fig, ax = plt.subplots(1, 3, figsize=(14, 8))
tfdiff.plot(logy=False, lw=3, ax=ax[0])
tfdiff.plot(logy=True, lw=3, ax=ax[1])
tfdiff.tail(60).plot(logy=True, lw=3, ax=ax[2])
ax[0].set_ylim(0)
ax[0].set_title(
    "Nombre de décès lissé sur 7 jours")

plt.show()
Nombre de décès lissé sur 7 jours

Total running time of the script: ( 0 minutes 22.214 seconds)

Gallery generated by Sphinx-Gallery