.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_covid_dashboard.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_covid_dashboard.py: Dashboard COVID France ====================== Graphe simple fait à partir des données sur open.data.gouv.fr. .. contents:: :local: Récupération des données ++++++++++++++++++++++++ .. GENERATED FROM PYTHON SOURCE LINES 14-36 .. code-block:: default import os from datetime import datetime, timedelta import matplotlib.pyplot as plt from pandas import read_csv, to_datetime now = datetime.now() name = "covid-%d-%02d-%02d.csv" % (now.year, now.month, now.day) if os.path.exists(name): covid = read_csv(name) else: url = ( "https://www.data.gouv.fr/en/datasets/r/" "d3a98a30-893f-47f7-96c5-2f4bcaaa0d71") covid = read_csv(url, sep=",") covid.to_csv(name, index=False) covid['date'] = to_datetime(covid['date']) now_4 = now - timedelta(120) covid = covid[covid.date >= now_4] covid = covid.set_index('date') covid.tail() .. raw:: html
total_cas_confirmes total_deces_hopital total_deces_ehpad total_cas_confirmes_ehpad total_cas_possibles_ehpad patients_reanimation patients_hospitalises total_patients_gueris nouveaux_patients_hospitalises nouveaux_patients_reanimation
date


.. GENERATED FROM PYTHON SOURCE LINES 37-39 Cas positifs et décès +++++++++++++++++++++ .. GENERATED FROM PYTHON SOURCE LINES 39-49 .. code-block:: default diff = covid.diff() fig, ax = plt.subplots(2, 1, figsize=(8, 8)) diff['cas_positifs'] = diff['total_cas_confirmes'].rolling( 7, center=False).mean() diff['deces'] = diff['total_deces_hopital'].rolling(7, center=False).mean() diff[["total_cas_confirmes", "cas_positifs"]].plot( ax=ax[0], title="Cas positifs") diff[["total_deces_hopital", "deces"]].plot(ax=ax[1], title="Décès") .. image-sg:: /auto_examples/images/sphx_glr_plot_covid_dashboard_001.png :alt: Cas positifs, Décès :srcset: /auto_examples/images/sphx_glr_plot_covid_dashboard_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 50-52 Hôpital +++++++ .. GENERATED FROM PYTHON SOURCE LINES 52-81 .. code-block:: default fig, ax = plt.subplots(3, 2, figsize=(12, 12)) covid['weeklyh'] = covid['nouveaux_patients_hospitalises'].rolling( 7, center=False).mean() covid['weeklyr'] = covid['nouveaux_patients_reanimation'].rolling( 7, center=False).mean() covid[["nouveaux_patients_hospitalises", "weeklyh"]].plot( ax=ax[0, 0], title="Hospitalisations") covid[["nouveaux_patients_reanimation", "weeklyr"]].plot( ax=ax[1, 0], title="Réanimations") diff['weeklyh'] = diff['patients_hospitalises'].rolling(7, center=False).mean() diff['weeklyg'] = diff['total_patients_gueris'].rolling(7, center=False).mean() diff['weeklyr'] = diff['patients_reanimation'].rolling(7, center=False).mean() diff[["patients_hospitalises", "weeklyh", "total_patients_gueris", "weeklyg"]].plot(ax=ax[0, 1], title="Delta Hospitalisations") diff[["patients_reanimation", "weeklyr"]].plot( ax=ax[1, 1], title="Delta Réanimations") covid['weeklyph'] = covid['patients_hospitalises'].rolling( 7, center=False).mean() covid['weeklypr'] = covid['patients_reanimation'].rolling( 7, center=False).mean() covid[["patients_hospitalises", "weeklyph"]].plot( ax=ax[2, 0], title="Lits Hospitalisations") covid[["patients_reanimation", "weeklypr"]].plot( ax=ax[2, 1], title="Lits Réanimations") plt.show() .. image-sg:: /auto_examples/images/sphx_glr_plot_covid_dashboard_002.png :alt: Hospitalisations, Delta Hospitalisations, Réanimations, Delta Réanimations, Lits Hospitalisations, Lits Réanimations :srcset: /auto_examples/images/sphx_glr_plot_covid_dashboard_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 4.461 seconds) .. _sphx_glr_download_auto_examples_plot_covid_dashboard.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_covid_dashboard.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_covid_dashboard.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_