From 77f8ef867bd69b19fdaf8fbdf06839ef503bae74 Mon Sep 17 00:00:00 2001 From: escuiller Date: Mon, 27 Apr 2020 16:22:41 +0200 Subject: [PATCH] =?UTF-8?q?passage=20des=20donn=C3=A9es=20en=20format=20pd?= =?UTF-8?q?.dataframe=20avec=20datetimeindex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module3/exo2/exercice_python_fr.org | 34 ++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/module3/exo2/exercice_python_fr.org b/module3/exo2/exercice_python_fr.org index c0c7481..58beab2 100644 --- a/module3/exo2/exercice_python_fr.org +++ b/module3/exo2/exercice_python_fr.org @@ -142,10 +142,11 @@ librairie pandas. ** Visualisation au pas semaine -#+begin_src python :results value :session :exports both +#+begin_src python :results output :session :exports both import pandas data = pandas.DataFrame(converted_data, columns=("Date", "Incidence")) -fig = data.plot(x="Date", y="Incidence") +data.set_index(pandas.to_datetime(data["Date"]), inplace=True) +fig = data.plot() plt.savefig("incidence_hebdo_varicelle.png") #+end_src @@ -153,5 +154,32 @@ plt.savefig("incidence_hebdo_varicelle.png") [[file:"incidence_hebdo_varicelle.png"]] -** Visualisation au pas année +Zoom sur une année pour situer à quel mois se situe de pic annuel. + +#+begin_src python :results output :session :exports both +#print(data.index) +fig2 = data["2002-01-01":"2002-12-31"].plot() +plt.savefig("incidence_hebdo_varicelle_2002.png") +#+end_src + +#+RESULTS: + +[[file:"incidence_hebdo_varicelle_2002.png"]] + +Le pic semble être au printemps de chaque année, légèrement plus tard +que le pic de grippe. + +** Analyse année par année + +La période de référence commence au 1er septembre. La période +commençant en septembre de l'année N a l'étiquette N+1 car le pic +annuel se situe en début/printemps de l'année N+1 (sur le modèle +de l'analyse du syndrome grippal dans le mooc). + +#+begin_src python :results output :session :exports both +incidence_annuelle = pandas.DataFrame() + +#+end_src + +#+RESULTS: -- 2.18.1