diff --git a/notebook_gouv/prix_carburant_gouv.ipynb b/notebook_gouv/prix_carburant_gouv.ipynb index f32427a5d6e07781b15d4af6850e6a57e1eb3023..87cf205637ea9a22cd2b30b6ea561d6fb87fb3ae 100644 --- a/notebook_gouv/prix_carburant_gouv.ipynb +++ b/notebook_gouv/prix_carburant_gouv.ipynb @@ -2255,8 +2255,8 @@ }, { "cell_type": "code", - "execution_count": 18, - "id": "058ae67f-3dd9-40cc-8215-f7a633028329", + "execution_count": 39, + "id": "581f9f82-9820-41a2-bed7-513c40626fb2", "metadata": { "tags": [] }, @@ -2282,7 +2282,6 @@ " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", - " <th>region</th>\n", " <th>carburant</th>\n", " <th>annee</th>\n", " <th>prix_moyen_par_hectolitre</th>\n", @@ -2290,105 +2289,35 @@ " </thead>\n", " <tbody>\n", " <tr>\n", - " <th>0</th>\n", - " <td>82</td>\n", - " <td>Gazole</td>\n", - " <td>2007</td>\n", - " <td>110.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>1</th>\n", - " <td>82</td>\n", - " <td>Gazole</td>\n", - " <td>2008</td>\n", - " <td>128.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>2</th>\n", - " <td>82</td>\n", - " <td>Gazole</td>\n", - " <td>2009</td>\n", - " <td>101.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>3</th>\n", - " <td>82</td>\n", - " <td>Gazole</td>\n", - " <td>2010</td>\n", - " <td>116.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>4</th>\n", - " <td>82</td>\n", - " <td>Gazole</td>\n", - " <td>2011</td>\n", - " <td>135.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>...</th>\n", - " <td>...</td>\n", - " <td>...</td>\n", - " <td>...</td>\n", - " <td>...</td>\n", - " </tr>\n", - " <tr>\n", - " <th>2517</th>\n", - " <td>75</td>\n", - " <td>GPLc</td>\n", - " <td>2019</td>\n", - " <td>87.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>2518</th>\n", - " <td>75</td>\n", - " <td>GPLc</td>\n", - " <td>2020</td>\n", - " <td>87.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>2519</th>\n", - " <td>75</td>\n", - " <td>GPLc</td>\n", + " <th>81</th>\n", + " <td>SP98</td>\n", " <td>2021</td>\n", - " <td>87.0</td>\n", + " <td>162.08</td>\n", " </tr>\n", " <tr>\n", - " <th>2520</th>\n", - " <td>75</td>\n", - " <td>GPLc</td>\n", + " <th>87</th>\n", + " <td>SP98</td>\n", " <td>2022</td>\n", - " <td>86.0</td>\n", + " <td>185.62</td>\n", " </tr>\n", " <tr>\n", - " <th>2521</th>\n", - " <td>75</td>\n", - " <td>GPLc</td>\n", + " <th>93</th>\n", + " <td>SP98</td>\n", " <td>2023</td>\n", - " <td>100.0</td>\n", + " <td>197.23</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", - "<p>2522 rows × 4 columns</p>\n", "</div>" ], "text/plain": [ - " region carburant annee prix_moyen_par_hectolitre\n", - "0 82 Gazole 2007 110.0\n", - "1 82 Gazole 2008 128.0\n", - "2 82 Gazole 2009 101.0\n", - "3 82 Gazole 2010 116.0\n", - "4 82 Gazole 2011 135.0\n", - "... ... ... ... ...\n", - "2517 75 GPLc 2019 87.0\n", - "2518 75 GPLc 2020 87.0\n", - "2519 75 GPLc 2021 87.0\n", - "2520 75 GPLc 2022 86.0\n", - "2521 75 GPLc 2023 100.0\n", - "\n", - "[2522 rows x 4 columns]" + " carburant annee prix_moyen_par_hectolitre\n", + "81 SP98 2021 162.08\n", + "87 SP98 2022 185.62\n", + "93 SP98 2023 197.23" ] }, - "execution_count": 18, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -2398,251 +2327,17 @@ "df_ann_hecto = pd.read_csv(\"prix_annuel_carburants_par_regions_litre.csv\", sep=\",\")\n", "df_ann_hecto[\"prix_moyen_par_hectolitre\"] = round(df_ann_hecto['prix_moyen_par_litre'] * 100,2)\n", "df_ann_hecto.drop([\"prix_moyen_par_litre\"], inplace=True, axis=1)\n", - "df_ann_hecto" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "id": "cf7934b5-ec63-41f6-b439-1eede448e103", - "metadata": { - "tags": [] - }, - "outputs": [ - { - "data": { - "text/plain": [ - "array(['region', 'carburant', 'annee', 'prix_moyen_par_hectolitre'],\n", - " dtype=object)" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df_ann_hecto.columns.values" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "id": "581f9f82-9820-41a2-bed7-513c40626fb2", - "metadata": { - "tags": [] - }, - "outputs": [ - { - "data": { - "text/html": [ - "<div>\n", - "<style scoped>\n", - " .dataframe tbody tr th:only-of-type {\n", - " vertical-align: middle;\n", - " }\n", - "\n", - " .dataframe tbody tr th {\n", - " vertical-align: top;\n", - " }\n", - "\n", - " .dataframe thead tr th {\n", - " text-align: left;\n", - " }\n", - "</style>\n", - "<table border=\"1\" class=\"dataframe\">\n", - " <thead>\n", - " <tr>\n", - " <th></th>\n", - " <th>annee</th>\n", - " <th>carburant</th>\n", - " <th>prix_moyen_par_hectolitre</th>\n", - " </tr>\n", - " </thead>\n", - " <tbody>\n", - " <tr>\n", - " <th>91</th>\n", - " <td>2023</td>\n", - " <td>Gazole</td>\n", - " <td>185.54</td>\n", - " </tr>\n", - " <tr>\n", - " <th>92</th>\n", - " <td>2023</td>\n", - " <td>SP95</td>\n", - " <td>193.00</td>\n", - " </tr>\n", - " <tr>\n", - " <th>93</th>\n", - " <td>2023</td>\n", - " <td>SP98</td>\n", - " <td>197.23</td>\n", - " </tr>\n", - " </tbody>\n", - "</table>\n", - "</div>" - ], - "text/plain": [ - " annee carburant prix_moyen_par_hectolitre\n", - "91 2023 Gazole 185.54\n", - "92 2023 SP95 193.00\n", - "93 2023 SP98 197.23" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ "# Supprime la région\n", "df_ann_hecto = df_ann_hecto.groupby(['annee', 'carburant']).agg({'prix_moyen_par_hectolitre': ['mean']}, as_index=False).round(2)\n", "df_ann_hecto.reset_index(inplace=True)\n", "df_ann_hecto.columns = [[\"annee\", \"carburant\", \"prix_moyen_par_hectolitre\"]]\n", - "\n", + "df_ann_hecto = df_ann_hecto[[\"carburant\", \"annee\", \"prix_moyen_par_hectolitre\"]]\n", + "df_ann_hecto.to_csv(r'prix_par_carburant_annee_hectolitre.csv',index = False, header=True)\n", + "df_ann_hecto = pd.read_csv(\"prix_par_carburant_annee_hectolitre.csv\")\n", + "df_ann_hecto.sort_values([\"carburant\", \"annee\"], inplace=True)\n", "df_ann_hecto.to_csv(r'prix_par_carburant_annee_hectolitre.csv',index = False, header=True)\n", "df_ann_hecto.tail(3)" ] - }, - { - "cell_type": "code", - "execution_count": 21, - "id": "ad5b8499-9eaf-4a8f-84c2-2237b94ab818", - "metadata": { - "tags": [] - }, - "outputs": [ - { - "data": { - "text/html": [ - "<div>\n", - "<style scoped>\n", - " .dataframe tbody tr th:only-of-type {\n", - " vertical-align: middle;\n", - " }\n", - "\n", - " .dataframe tbody tr th {\n", - " vertical-align: top;\n", - " }\n", - "\n", - " .dataframe thead tr th {\n", - " text-align: left;\n", - " }\n", - "</style>\n", - "<table border=\"1\" class=\"dataframe\">\n", - " <thead>\n", - " <tr>\n", - " <th></th>\n", - " <th>annee</th>\n", - " <th>carburant</th>\n", - " <th>prix_moyen_par_hectolitre</th>\n", - " </tr>\n", - " </thead>\n", - " <tbody>\n", - " <tr>\n", - " <th>0</th>\n", - " <td>2007</td>\n", - " <td>E85</td>\n", - " <td>82.24</td>\n", - " </tr>\n", - " <tr>\n", - " <th>1</th>\n", - " <td>2007</td>\n", - " <td>GPLc</td>\n", - " <td>73.27</td>\n", - " </tr>\n", - " <tr>\n", - " <th>2</th>\n", - " <td>2007</td>\n", - " <td>Gazole</td>\n", - " <td>110.09</td>\n", - " </tr>\n", - " <tr>\n", - " <th>3</th>\n", - " <td>2007</td>\n", - " <td>SP95</td>\n", - " <td>129.48</td>\n", - " </tr>\n", - " <tr>\n", - " <th>4</th>\n", - " <td>2008</td>\n", - " <td>E85</td>\n", - " <td>85.82</td>\n", - " </tr>\n", - " <tr>\n", - " <th>...</th>\n", - " <td>...</td>\n", - " <td>...</td>\n", - " <td>...</td>\n", - " </tr>\n", - " <tr>\n", - " <th>89</th>\n", - " <td>2023</td>\n", - " <td>E85</td>\n", - " <td>115.00</td>\n", - " </tr>\n", - " <tr>\n", - " <th>90</th>\n", - " <td>2023</td>\n", - " <td>GPLc</td>\n", - " <td>102.69</td>\n", - " </tr>\n", - " <tr>\n", - " <th>91</th>\n", - " <td>2023</td>\n", - " <td>Gazole</td>\n", - " <td>185.54</td>\n", - " </tr>\n", - " <tr>\n", - " <th>92</th>\n", - " <td>2023</td>\n", - " <td>SP95</td>\n", - " <td>193.00</td>\n", - " </tr>\n", - " <tr>\n", - " <th>93</th>\n", - " <td>2023</td>\n", - " <td>SP98</td>\n", - " <td>197.23</td>\n", - " </tr>\n", - " </tbody>\n", - "</table>\n", - "<p>94 rows × 3 columns</p>\n", - "</div>" - ], - "text/plain": [ - " annee carburant prix_moyen_par_hectolitre\n", - "0 2007 E85 82.24\n", - "1 2007 GPLc 73.27\n", - "2 2007 Gazole 110.09\n", - "3 2007 SP95 129.48\n", - "4 2008 E85 85.82\n", - ".. ... ... ...\n", - "89 2023 E85 115.00\n", - "90 2023 GPLc 102.69\n", - "91 2023 Gazole 185.54\n", - "92 2023 SP95 193.00\n", - "93 2023 SP98 197.23\n", - "\n", - "[94 rows x 3 columns]" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df_ann_hecto" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "40fd5c27-a827-47d7-912e-072dc71ca860", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/notebook_gouv/prix_par_carburant_annee_hectolitre.csv b/notebook_gouv/prix_par_carburant_annee_hectolitre.csv index d23ca4e43329ee4edaa60b50ff9c942a8072c366..1cb761027006ad0d0b129838f6ece266211c246f 100644 --- a/notebook_gouv/prix_par_carburant_annee_hectolitre.csv +++ b/notebook_gouv/prix_par_carburant_annee_hectolitre.csv @@ -1,95 +1,95 @@ carburant,annee,prix_moyen_par_hectolitre +E10,2009,123.95 +E10,2010,136.0 +E10,2011,151.87 +E10,2012,157.29 +E10,2013,155.62 +E10,2014,150.04 +E10,2015,136.87 +E10,2016,128.93 +E10,2017,137.64 +E10,2018,150.77 +E10,2019,150.62 +E10,2020,136.92 +E10,2021,154.69 +E10,2022,179.0 +E10,2023,189.92 E85,2007,82.24 -GPLc,2007,73.27 -Gazole,2007,110.09 -SP95,2007,129.48 E85,2008,85.82 -GPLc,2008,75.73 -Gazole,2008,128.09 -SP95,2008,137.83 -E10,2009,123.95 E85,2009,95.36 -GPLc,2009,66.64 -Gazole,2009,101.35 -SP95,2009,122.74 -E10,2010,136.0 E85,2010,110.73 -GPLc,2010,72.95 -Gazole,2010,116.22 -SP95,2010,136.77 -E10,2011,151.87 E85,2011,90.32 -GPLc,2011,83.52 -Gazole,2011,136.25 -SP95,2011,152.88 -E10,2012,157.29 E85,2012,92.09 -GPLc,2012,87.48 -Gazole,2012,142.54 -SP95,2012,160.17 -E10,2013,155.62 E85,2013,93.14 -GPLc,2013,88.3 -Gazole,2013,138.21 -SP95,2013,157.04 -SP98,2013,159.52 -E10,2014,150.04 E85,2014,88.33 -GPLc,2014,86.78 -Gazole,2014,131.42 -SP95,2014,151.48 -SP98,2014,155.96 -E10,2015,136.87 E85,2015,91.36 -GPLc,2015,80.59 -Gazole,2015,117.3 -SP95,2015,137.95 -SP98,2015,141.91 -E10,2016,128.93 E85,2016,83.08 -GPLc,2016,73.92 -Gazole,2016,112.93 -SP95,2016,133.08 -SP98,2016,136.62 -E10,2017,137.64 E85,2017,73.15 -GPLc,2017,77.31 -Gazole,2017,126.14 -SP95,2017,140.77 -SP98,2017,145.54 -E10,2018,150.77 E85,2018,77.23 -GPLc,2018,85.62 -Gazole,2018,146.0 -SP95,2018,153.46 -SP98,2018,157.92 -E10,2019,150.62 E85,2019,76.46 -GPLc,2019,88.46 -Gazole,2019,146.38 -SP95,2019,153.54 -SP98,2019,158.23 -E10,2020,136.92 E85,2020,71.08 -GPLc,2020,88.23 -Gazole,2020,129.0 -SP95,2020,139.15 -SP98,2020,143.62 -E10,2021,154.69 E85,2021,74.54 -GPLc,2021,89.15 -Gazole,2021,145.62 -SP95,2021,157.69 -SP98,2021,162.08 -E10,2022,179.0 E85,2022,91.38 -GPLc,2022,89.15 -Gazole,2022,187.62 -SP95,2022,184.54 -SP98,2022,185.62 -E10,2023,189.92 E85,2023,115.0 +GPLc,2007,73.27 +GPLc,2008,75.73 +GPLc,2009,66.64 +GPLc,2010,72.95 +GPLc,2011,83.52 +GPLc,2012,87.48 +GPLc,2013,88.3 +GPLc,2014,86.78 +GPLc,2015,80.59 +GPLc,2016,73.92 +GPLc,2017,77.31 +GPLc,2018,85.62 +GPLc,2019,88.46 +GPLc,2020,88.23 +GPLc,2021,89.15 +GPLc,2022,89.15 GPLc,2023,102.69 +Gazole,2007,110.09 +Gazole,2008,128.09 +Gazole,2009,101.35 +Gazole,2010,116.22 +Gazole,2011,136.25 +Gazole,2012,142.54 +Gazole,2013,138.21 +Gazole,2014,131.42 +Gazole,2015,117.3 +Gazole,2016,112.93 +Gazole,2017,126.14 +Gazole,2018,146.0 +Gazole,2019,146.38 +Gazole,2020,129.0 +Gazole,2021,145.62 +Gazole,2022,187.62 Gazole,2023,185.54 +SP95,2007,129.48 +SP95,2008,137.83 +SP95,2009,122.74 +SP95,2010,136.77 +SP95,2011,152.88 +SP95,2012,160.17 +SP95,2013,157.04 +SP95,2014,151.48 +SP95,2015,137.95 +SP95,2016,133.08 +SP95,2017,140.77 +SP95,2018,153.46 +SP95,2019,153.54 +SP95,2020,139.15 +SP95,2021,157.69 +SP95,2022,184.54 SP95,2023,193.0 +SP98,2013,159.52 +SP98,2014,155.96 +SP98,2015,141.91 +SP98,2016,136.62 +SP98,2017,145.54 +SP98,2018,157.92 +SP98,2019,158.23 +SP98,2020,143.62 +SP98,2021,162.08 +SP98,2022,185.62 SP98,2023,197.23