From 53e0e9eda91478dd39a87734065b0fb8174bc05d Mon Sep 17 00:00:00 2001 From: aschmitt <aurelien.schmitt@sb-roscoff.fr> Date: Thu, 4 Jul 2024 17:15:19 +0200 Subject: [PATCH] modification du pivot table pour retirer les colonnes en index --- src/ETL_cotier_wp5.ipynb | 50 +++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/src/ETL_cotier_wp5.ipynb b/src/ETL_cotier_wp5.ipynb index 7a00976..c4c190e 100644 --- a/src/ETL_cotier_wp5.ipynb +++ b/src/ETL_cotier_wp5.ipynb @@ -3230,12 +3230,48 @@ "outputs": [], "execution_count": null }, + { + "cell_type": "markdown", + "source": [], + "metadata": { + "collapsed": false + }, + "id": "d2a989ec9b31e51f" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "## 7. Valeur inférieur à Ld et LQ valent 0" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-07-04T15:13:39.113059900Z", + "start_time": "2024-07-04T15:13:39.093058700Z" + } + }, + "id": "94b992787053a521", + "execution_count": 1 + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "rephy_wp5.loc[rephy_wp5['RESULTAT'].str.contains('valeur', na=False), 'RESULTAT'] = 0\n", + "rephy_wp5.loc[rephy_wp5['RESULTAT'].str.contains('Inf.', na=False), 'RESULTAT'] = 0" + ], + "metadata": { + "collapsed": false + }, + "id": "47aa00346655beea" + }, { "cell_type": "markdown", "id": "2b0db6dc", "metadata": {}, "source": [ - "## 7. Création des tables transposées des paramètres" + "## 8. Création des tables transposées des paramètres" ] }, { @@ -3243,11 +3279,13 @@ "id": "57ab4e93", "metadata": {}, "source": [ - "vals = list(['RESULTAT','NIVEAU_QUALITE','RESULTAT_COMMENTAIRE'])\n", - "ind = list(['LIEU_LIBELLE','LIEU_IDENTIFIANT', 'DATE', 'LATITUDE', 'LONGITUDE','SOURCE','DOI'])\n", - "cols = list([\"PARAMETRE_CODE\",\"TYPE_METHODE\"])\n", - "rephyT = pd.pivot_table(rephy_wp5 , values=vals, index=ind, columns=cols, aggfunc=[np.max], fill_value='')\n", - "rephyT.columns\n" + "vals = list(['RESULTAT'])\n", + "ind = list(['LIEU_LIBELLE','LIEU_IDENTIFIANT', 'DATE', 'LATITUDE', 'LONGITUDE'])\n", + "cols = list([\"PARAMETRE_CODE\"])\n", + "rephyT_no_methodes = pd.pivot_table(rephy_wp5 , values=vals, index=ind, columns=cols, aggfunc=[np.max], fill_value='').reset_index(col_level=2)\n", + "\n", + "rephyT_no_methodes.columns = rephyT_no_methodes.columns.droplevel(1).droplevel(0)\n", + "rephyT_no_methodes.shape\n" ], "outputs": [], "execution_count": null -- GitLab