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 ... 1/29/23 1/30/23 1/31/23 2/1/23 2/2/23 2/3/23 2/4/23 2/5/23 2/6/23 2/7/23 2/8/23 2/9/23 2/10/23 2/11/23 2/12/23 2/13/23 2/14/23 2/15/23 2/16/23 2/17/23 2/18/23 2/19/23 2/20/23 2/21/23 2/22/23 2/23/23 2/24/23 2/25/23 2/26/23 2/27/23 2/28/23 3/1/23 3/2/23 3/3/23 3/4/23 3/5/23 3/6/23 3/7/23 3/8/23 3/9/23
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 ... 7876 7879 7882 7882 7891 7891 7894 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896 7896
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 ... 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3596 3598 3598 3598 3598 3598 3598 3598 3598 3598 3598 3598 3598 3598 3598 3598 3598
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 ... 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881 6881
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 ... 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165
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 ... 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1931 1933 1933 1933 1933 1933 1933 1933 1933 1933 1933 1933

5 rows × 1147 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 ... 1/29/23 1/30/23 1/31/23 2/1/23 2/2/23 2/3/23 2/4/23 2/5/23 2/6/23 2/7/23 2/8/23 2/9/23 2/10/23 2/11/23 2/12/23 2/13/23 2/14/23 2/15/23 2/16/23 2/17/23 2/18/23 2/19/23 2/20/23 2/21/23 2/22/23 2/23/23 2/24/23 2/25/23 2/26/23 2/27/23 2/28/23 3/1/23 3/2/23 3/3/23 3/4/23 3/5/23 3/6/23 3/7/23 3/8/23 3/9/23
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 ... 208435 208502 208545 208552 208669 208669 208621 208627 208704 208721 208771 208771 208943 208971 208982 209011 209036 209056 209072 209083 209084 209107 209153 209181 209181 209215 209230 209246 209274 209308 209322 209340 209358 209362 209369 209390 209406 209436 209451 209451
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 ... 334157 334157 334167 334177 334187 334203 334204 334211 334211 334211 334222 334229 334229 334234 334255 334255 334264 334264 334273 334291 334305 334314 334315 334336 334336 334345 334356 334373 334378 334380 334391 334408 334408 334427 334427 334427 334427 334427 334443 334457
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 ... 271376 271376 271378 271385 271386 271394 271394 271394 271395 271399 271403 271406 271406 271409 271409 271409 271409 271421 271424 271424 271425 271425 271426 271428 271431 271432 271436 271439 271440 271440 271441 271448 271463 271469 271469 271477 271477 271490 271494 271496
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 ... 47839 47839 47839 47839 47839 47850 47850 47850 47850 47850 47850 47860 47860 47860 47860 47860 47860 47860 47866 47866 47866 47866 47866 47866 47866 47866 47866 47866 47866 47866 47866 47875 47875 47875 47875 47875 47875 47875 47890 47890
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 ... 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105184 105205 105205 105205 105205 105205 105255 105255 105277 105277 105277 105277 105277 105277 105277 105288 105288

5 rows × 1147 columns



Tous les pays

print(" --- ".join(sorted(set(df['Country/Region']))))
Afghanistan --- Albania --- Algeria --- Andorra --- Angola --- Antarctica --- 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, North --- 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 --- Nauru --- 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 --- Tonga --- Trinidad and Tobago --- Tunisia --- Turkey --- Tuvalu --- US --- Uganda --- Ukraine --- United Arab Emirates --- United Kingdom --- Uruguay --- Uzbekistan --- Vanuatu --- Venezuela --- Vietnam --- West Bank and Gaza --- Winter Olympics 2022 --- 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 ... 1/29/23 1/30/23 1/31/23 2/1/23 2/2/23 2/3/23 2/4/23 2/5/23 2/6/23 2/7/23 2/8/23 2/9/23 2/10/23 2/11/23 2/12/23 2/13/23 2/14/23 2/15/23 2/16/23 2/17/23 2/18/23 2/19/23 2/20/23 2/21/23 2/22/23 2/23/23 2/24/23 2/25/23 2/26/23 2/27/23 2/28/23 3/1/23 3/2/23 3/3/23 3/4/23 3/5/23 3/6/23 3/7/23 3/8/23 3/9/23
24 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 ... 33557 33557 33557 33557 33582 33582 33582 33582 33582 33582 33582 33616 33616 33616 33616 33616 33616 33616 33616 33663 33663 33663 33663 33663 33663 33717 33717 33717 33717 33717 33717 33717 33775 33775 33775 33775 33775 33775 33775 33814
131 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 ... 160468 160561 160618 160671 160723 160751 160751 160751 160812 160849 160880 160897 160917 160917 160917 160965 161000 161035 161062 161090 161090 161090 161137 161169 161206 161225 161254 161254 161254 161306 161340 161365 161386 161407 161407 161407 161450 161474 161501 161512
135 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 ... 165441 165563 165711 165865 166016 166128 166128 166128 166292 166399 166526 166660 166660 166763 166763 166875 166999 167124 167214 167301 167301 167301 167387 167491 167604 167723 167812 167812 167812 167951 168086 168175 168296 168397 168397 168397 168397 168709 168808 168935
154 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 ... 186833 186833 186833 186833 186833 187272 187272 187272 187272 187272 187272 187272 187551 187551 187551 187551 187551 187551 187551 187850 187850 187850 187850 187850 187850 187850 188094 188094 188094 188094 188094 188094 188094 188322 188322 188322 188322 188322 188322 188322
241 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 ... 118434 118434 118434 118434 118434 118712 118712 118712 118712 118712 118712 118712 118976 118976 118976 118976 118976 118976 118976 119186 119186 119186 119186 119186 119186 119186 119380 119380 119380 119380 119380 119380 119380 119479 119479 119479 119479 119479 119479 119479
260 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 ... 1107690 1107918 1108688 1109996 1111159 1111679 1111696 1111698 1111890 1112362 1113429 1114385 1114492 1114529 1114537 1114709 1115160 1115741 1116851 1117572 1117589 1117590 1117663 1118025 1118886 1119521 1119573 1119587 1119588 1119582 1119917 1120897 1121658 1122165 1122172 1122134 1122181 1122516 1123246 1123836
278 NaN United Kingdom 55.378100 -3.436000 0 0 0 0 0 0 0 0 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 ... 219182 219240 219298 219362 219432 219500 219562 219633 219686 219751 219819 219880 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948 219948

7 rows × 1147 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
3/5/23 33775 161407 168397 188322 119479 1122134 219948
3/6/23 33775 161450 168397 188322 119479 1122181 219948
3/7/23 33775 161474 168709 188322 119479 1122516 219948
3/8/23 33775 161501 168808 188322 119479 1123246 219948
3/9/23 33814 161512 168935 188322 119479 1123836 219948


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
3/5/23 4727795 38591184 38210851 25603510 13770429 103646975 24396530
3/6/23 4727795 38599330 38210851 25603510 13770429 103655539 24396530
3/7/23 4727795 38606393 38231610 25603510 13770429 103690910 24396530
3/8/23 4727795 38612201 38241231 25603510 13770429 103755771 24396530
3/9/23 4739365 38618509 38249060 25603510 13770429 103802702 24425309


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
3/5/23 33750.142857 161374.000000 168242.714286 188191.714286 119422.428571 1.121218e+06 219948.0
3/6/23 33758.428571 161394.571429 168306.428571 188224.285714 119436.571429 1.121589e+06 219948.0
3/7/23 33766.714286 161413.714286 168395.428571 188256.857143 119450.714286 1.121960e+06 219948.0
3/8/23 33775.000000 161433.142857 168485.857143 188289.428571 119464.857143 1.122296e+06 219948.0
3/9/23 33780.571429 161451.142857 168577.142857 188322.000000 119479.000000 1.122607e+06 219948.0


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])
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 11.714286 14.142857 9.428571 14.857143 13.857143
1 13.571429 16.142857 15.428571 18.571429 14.285714 17.857143 18.428571
2 22.571429 22.428571 21.000000 25.000000 21.714286 21.000000 25.000000
3 32.714286 28.285714 27.142857 34.857143 29.142857 25.428571 34.571429
4 44.571429 38.285714 37.571429 48.428571 47.428571 30.714286 48.285714


Belgium France Germany Italy Spain US United Kingdom
1100 NaN NaN NaN 188191.714286 NaN NaN NaN
1101 NaN NaN NaN 188224.285714 NaN NaN NaN
1102 NaN NaN NaN 188256.857143 NaN NaN NaN
1103 NaN NaN NaN 188289.428571 NaN NaN NaN
1104 NaN NaN NaN 188322.000000 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 10 92 -1918 600 279
8/12/20 15 17 6 10 -2 1532 24
3/29/22 0 157 307 177 -174 761 195
5/24/22 0 79 159 95 -5 344 51
8/2/22 0 86 171 190 -6 519 101
9/7/22 14 46 120 57 -8 779 59
10/24/22 37 172 204 39 -4 209 104
11/12/22 0 0 0 0 -65 5 46


Et pour la France.

neg[neg['France'] < 0]
Belgium France Germany Italy Spain US United Kingdom
5/19/20 28 -217 72 162 69 1427 372
5/24/20 43 -82 31 50 74 636 281
7/21/20 0 -14 4 15 2 1073 31
9/4/20 2 -22 1 11 184 950 15
10/25/20 73 -21 29 128 0 452 255
11/4/20 205 -38 151 352 1623 1081 340
2/4/21 44 -4 786 421 432 3881 826
7/14/21 0 -6 28 23 10 324 47
8/28/21 0 -46 0 54 0 654 134
2/9/22 68 -37 272 384 282 3335 144
1/25/23 0 -22 138 0 0 1368 66


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'])))
somewhereaftercovid_39_std/aftercovid/aftercovid/preprocess/ts.py:96: RuntimeWarning: invalid value encountered in 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 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,28.0,29.0,32.0,30.428571428565192,26.428571428579744,22.571428571420256,22.571428571434808,22.571428571420256,22.28571428572468,26.71428571427532,29.571428571434808,31.428571428565192,33.71428571428987,33.71428571428987,33.71428571428987,26.0,26.428571428565192,24.714285714289872,22.142857142855064,19.428571428565192,19.428571428579744,19.428571428565192,27.142857142855064,19.28571428572468,22.142857142855064,24.285714285710128,24.142857142855064,24.142857142855064,24.142857142855064,22.571428571434808,26.714285714289872,22.571428571420256,22.428571428579744,19.571428571420256,19.571428571434808,19.571428571420256,16.571428571434808,17.285714285710128,18.428571428579744,18.142857142855064,20.714285714289872,20.71428571427532,20.714285714289872,25.142857142855064,26.571428571434808,25.142857142855064,27.285714285710128,29.142857142855064,29.142857142855064,29.142857142869616,21.571428571420256,26.428571428579744,22.428571428565192,28.428571428565192,31.571428571434808,31.714285714289872,31.71428571427532,46.428571428579744,43.571428571420256,54.57142857143481,49.42857142856519,46.857142857144936,46.71428571428987,46.71428571428987,44.142857142855064,49.28571428571013,45.428571428579744,50.28571428571013,44.42857142856519,44.428571428579744,44.42857142856519,49.428571428579744,52.28571428571013,56.28571428571013,55.142857142855064,55.142857142855064,55.142857142869616,55.142857142855064,62.0,62.28571428571013,72.28571428571013,61.71428571428987,75.57142857143481,75.57142857142026,75.57142857143481,80.42857142856519,99.14285714285506,95.85714285714494,111.85714285714494,117.85714285714494,117.85714285714494,117.85714285714494,122.42857142856519,127.71428571428987,132.71428571427532,139.85714285714494,140.28571428572468,140.28571428571013,140.28571428571013,143.0,157.0,164.85714285714494,166.85714285714494,175.0,175.0,175.0,175.85714285714494,179.57142857142026,180.85714285714494,181.85714285714494,153.4285714285652,153.42857142857974,153.4285714285652,192.14285714285506,185.42857142857974,193.71428571428987,223.71428571427532,279.2857142857247,279.2857142857101,279.2857142857101,289.42857142857974,282.14285714285506,305.2857142857101,300.5714285714348,286.14285714285506,286.14285714285506,286.14285714285506,266.5714285714348,247.0,226.57142857142026,207.42857142857974,201.71428571427532,201.71428571428987,201.71428571428987,135.4285714285652,178.28571428571013,157.28571428572468,153.85714285714494,143.28571428571013,143.28571428571013,143.28571428571013,166.28571428572468,139.4285714285652,136.42857142857974,119.71428571427532,103.14285714285506,103.14285714286962,103.14285714285506,80.14285714285506,79.57142857142026,60.57142857143481,48.42857142856519,81.14285714286962,81.14285714285506,81.14285714285506,81.14285714285506,91.0,91.0,91.0,98.42857142856519,98.42857142857974,98.42857142856519,98.42857142857974,23.571428571420256,23.571428571434808,23.571428571420256,21.28571428572468,21.285714285710128,21.285714285710128,21.28571428572468,75.57142857142026,75.57142857143481,75.57142857142026,80.42857142857974,80.42857142856519,80.42857142857974,80.42857142856519,51.0,51.0,51.0,0.0,0.0,0.0,0.0,0.0,88.14285714285506,88.14285714285506,114.85714285714494,114.85714285714494,114.85714285714494,114.85714285714494,160.4285714285652,72.28571428571013,72.28571428572468,78.28571428571013,78.28571428571013,78.28571428572468,78.28571428571013,63.0,63.0,63.0,59.0,59.0,59.0,95.28571428571013,65.0,65.0,65.0,82.14285714285506,82.14285714285506,82.14285714286962,45.857142857130384,74.14285714286962,74.14285714285506,74.14285714285506,28.285714285710128,72.57142857143481,72.57142857142026,72.57142857143481,43.571428571420256,43.57142857143481,66.14285714285506,99.85714285714494,55.57142857143481,55.571428571420256,55.57142857143481,56.28571428571013,78.0,55.42857142856519,65.14285714286962,65.14285714285506,65.14285714285506,65.14285714285506,81.85714285714494,60.142857142855064,60.142857142855064,44.428571428579744,44.42857142856519,44.42857142856519,44.428571428579744,46.42857142856519,46.428571428579744,46.42857142856519,53.428571428579744,53.42857142856519,53.42857142856519,53.428571428579744,52.142857142855064,52.142857142855064,52.142857142855064,45.28571428572468,45.28571428571013,45.28571428571013,45.28571428571013,43.142857142869616,43.142857142855064,43.142857142855064,44.571428571420256,44.57142857143481,44.57142857143481,44.571428571420256,50.428571428579744,50.42857142856519,50.42857142856519,88.42857142857974,88.42857142856519,88.42857142857974,88.42857142856519,102.14285714285506,102.14285714285506,102.14285714286962,88.28571428571013,88.28571428571013,88.28571428571013,88.28571428572468,95.42857142856519,95.42857142857974,95.42857142856519,119.85714285714494,119.85714285714494,119.85714285714494,119.85714285713038,107.42857142857974,107.42857142856519,107.42857142857974,76.0,76.0,76.0,76.0,45.571428571420256,45.57142857143481,45.571428571420256,53.57142857143481,53.57142857143481,53.571428571420256,53.57142857143481,89.42857142856519,89.42857142857974,89.42857142856519,81.85714285714494,81.85714285714494,81.85714285714494,81.85714285713038,81.0,81.0,81.0,65.85714285714494,65.85714285714494,65.85714285714494,65.85714285714494,48.571428571420256,48.57142857143481,48.57142857143481,46.571428571420256,46.57142857143481,46.571428571420256,46.57142857143481,50.571428571420256,50.57142857143481,50.57142857143481,50.0,50.0,50.0,50.0,47.28571428571013,46.142857142855064,46.142857142855064,46.57142857143481,46.571428571420256,46.57142857143481,46.571428571420256,49.71428571428987,50.857142857144936,50.857142857144936,85.0,85.0,85.0,85.0,80.85714285714494,80.85714285714494,80.85714285713038,40.57142857143481,40.57142857143481,40.571428571420256,40.57142857143481,34.142857142855064,34.142857142855064,34.142857142855064,24.285714285710128,24.28571428572468,24.285714285710128,24.285714285710128,25.428571428579744,25.428571428565192,25.428571428579744,41.28571428571013,41.28571428571013,41.28571428571013,41.28571428572468,29.428571428565192,29.428571428579744,29.428571428565192,24.714285714289872,24.71428571427532,24.714285714289872,24.714285714289872,24.714285714289872,24.71428571427532,24.714285714289872,31.571428571434808,31.571428571420256,31.571428571434808,31.0,31.0,31.0,31.0,30.857142857144936,30.857142857130384,30.857142857144936,31.428571428579744,31.428571428565192,31.428571428579744,31.428571428565192,23.0,23.0,23.0,23.0,23.0,23.0,23.0,26.142857142855064,16.857142857144936,16.857142857144936,16.857142857144936,16.857142857144936,16.857142857130384,16.857142857144936,31.28571428572468,40.571428571420256,40.57142857143481,40.571428571420256,40.57142857143481,40.571428571420256,40.57142857143481,37.142857142855064,37.142857142855064,37.142857142855064,37.142857142869616,37.142857142855064,37.142857142855064,37.142857142855064,29.571428571434808,29.571428571420256,29.571428571434808,29.571428571420256,29.571428571434808,29.571428571420256,29.571428571434808,44.857142857144936,44.857142857144936,44.857142857144936,44.857142857130384,44.857142857144936,44.857142857144936,44.857142857144936,33.71428571428987,33.71428571427532,33.71428571428987,33.71428571428987,33.71428571428987,33.71428571427532,33.71428571428987,34.42857142856519,34.428571428579744,34.42857142856519,34.428571428579744,34.42857142856519,34.428571428579744,34.42857142856519,28.0,28.0,28.0,28.0,28.0,28.0,73.42857142856519,45.428571428579744,45.42857142856519,45.428571428579744,45.42857142856519,45.428571428579744,45.42857142856519,0.0,49.42857142856519,49.428571428579744,49.42857142856519,49.428571428579744,49.42857142856519,49.428571428579744,49.42857142856519,60.57142857143481,60.571428571420256,60.57142857143481,60.571428571420256,60.57142857143481,60.571428571420256,60.57142857143481,35.857142857144936,35.857142857144936,35.857142857144936,35.857142857130384,35.857142857144936,35.857142857144936,35.857142857144936,39.71428571428987,39.71428571427532,39.71428571428987,39.71428571428987,39.71428571428987,39.71428571427532,39.71428571428987,37.71428571428987,37.71428571427532,37.71428571428987,37.71428571428987,37.71428571428987,37.71428571427532,37.71428571428987,30.0,30.0,30.0,30.0,30.0,30.0,30.0,27.714285714289872,27.71428571427532,27.714285714289872,27.714285714289872,27.714285714289872,27.71428571427532,27.714285714289872,14.142857142855064,14.142857142855064,14.142857142855064,14.142857142869616,14.142857142855064,14.142857142855064,14.142857142855064,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 28.305 seconds)

Gallery generated by Sphinx-Gallery