{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Traitement de données avec python\n", "\n", "Dans ce TP, vous allez explorer concernant la population de toutes les villes française dans un premier temps puis les festivals.\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Villes de France\n", "\n", "À côté de ce document, vous trouverez un document `villes.csv` . Le copier dans son dossier personnel puis l'ouvrir avec notepad++\n", "\n", "### Description des données\n", "\n", "1. Décrire le format du fichier.\n", "2. Quelles sont les informations stockées dans ce fichier?\n", "3. À quoi correspond chaque ligne?\n", "3. Combien de lignes va-t-on pouvoir étudier?\n", "\n", "4. Rédiger deux questions qui pourrait être répondu en utilisant ce tableau.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Ouverture et manipulation avec python\n", "\n", "Ouvrir pythonedu, copier/coller le programme ci-dessous et sauvegarder votre script (vide) dans le même dossier où vous avez mis le fichier `villes.csv`.\n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "villes = pd.read_csv(\"villes.csv\")\n", "print(villes)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "6. Executer ce programme. Que fait-il? Commenter ce qui s'est écrit dans la console." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Festivals en France\n", "\n", "1. Aller sur la [plateforme d'opendata de l'état français](https://www.data.gouv.fr/fr/) et trouver des données sur les festivals de France\n", "2. Décrire les données trouvée\n", "3. Trouver 2 questions et essayer d'y répondre en utilisant Python" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Mémo Python et pandas" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Séléctionner une information\n", "\n", "- Séléctionner une ligne (ici la ligne 2)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dep 1\n", "nom Plagne\n", "cp 1130\n", "nb_hab_2010 129\n", "nb_hab_1999 83\n", "nb_hab_2012 100\n", "dens 20\n", "surf 6.2\n", "long 5.73333\n", "lat 46.1833\n", "alt_min 560\n", "alt_max 922\n", "Name: 2, dtype: object" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "villes.iloc[2]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Séléctionner une seule information (ici `cp` de la ligne 2)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'1130'" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "villes.loc[2,'cp']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Séléctionner tout une colonne (ici `nom`)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0 Ozan\n", "1 Cormoranche-sur-Saône\n", "2 Plagne\n", "3 Tossiat\n", "4 Pouillat\n", " ... \n", "36695 Sada\n", "36696 Tsingoni\n", "36697 Saint-Barthélemy\n", "36698 Saint-Martin\n", "36699 Saint-Pierre-et-Miquelon\n", "Name: nom, Length: 36700, dtype: object" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "villes[\"nom\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Séléctionner les lignes suivant une caractéristique (ici les villes avec une altitude minimum supérieur à 1500)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
depnomcpnb_hab_2010nb_hab_1999nb_hab_2012denssurflonglatalt_minalt_max
16184Larche45407483100168.866.8500044.45001606.03165.0
17905Ristolas54609078100182.186.9500044.76671571.03294.0
17985Saint-Véran5350257265300544.756.8666744.70001756.03175.0
18475Molines-en-Queyras5350315322300553.626.8500044.73331625.03160.0
19045Abriès5460365358400477.136.9333344.78331513.03305.0
19235Villar-d'Arêne5480287217300377.516.3371145.04231519.03883.0
2692766La Llagonne662102422643001023.092.1166742.53331546.02196.0
2694366Caudiès-de-Conflent66360136026.502.1613942.56731616.02045.0
2703966Porté-Puymorens66760131147100249.421.8333342.55001557.02827.0
2712566Mont-Louis662102472723006330.392.1166742.51671516.01608.0
2713466Angles662105665896001343.202.0744542.57781531.02808.0
2997073Bessans734803433103002128.086.9916745.31671673.03754.0
3011473Val-d'Isère731501563162816001694.396.9833345.45001785.03599.0
3012773Bonneval-sur-Arc73480241239200282.727.0500045.36671759.03642.0
\n", "
" ], "text/plain": [ " dep nom cp nb_hab_2010 nb_hab_1999 nb_hab_2012 \\\n", "1618 4 Larche 4540 74 83 100 \n", "1790 5 Ristolas 5460 90 78 100 \n", "1798 5 Saint-Véran 5350 257 265 300 \n", "1847 5 Molines-en-Queyras 5350 315 322 300 \n", "1904 5 Abriès 5460 365 358 400 \n", "1923 5 Villar-d'Arêne 5480 287 217 300 \n", "26927 66 La Llagonne 66210 242 264 300 \n", "26943 66 Caudiès-de-Conflent 66360 13 6 0 \n", "27039 66 Porté-Puymorens 66760 131 147 100 \n", "27125 66 Mont-Louis 66210 247 272 300 \n", "27134 66 Angles 66210 566 589 600 \n", "29970 73 Bessans 73480 343 310 300 \n", "30114 73 Val-d'Isère 73150 1563 1628 1600 \n", "30127 73 Bonneval-sur-Arc 73480 241 239 200 \n", "\n", " dens surf long lat alt_min alt_max \n", "1618 1 68.86 6.85000 44.4500 1606.0 3165.0 \n", "1790 1 82.18 6.95000 44.7667 1571.0 3294.0 \n", "1798 5 44.75 6.86667 44.7000 1756.0 3175.0 \n", "1847 5 53.62 6.85000 44.7333 1625.0 3160.0 \n", "1904 4 77.13 6.93333 44.7833 1513.0 3305.0 \n", "1923 3 77.51 6.33711 45.0423 1519.0 3883.0 \n", "26927 10 23.09 2.11667 42.5333 1546.0 2196.0 \n", "26943 2 6.50 2.16139 42.5673 1616.0 2045.0 \n", "27039 2 49.42 1.83333 42.5500 1557.0 2827.0 \n", "27125 633 0.39 2.11667 42.5167 1516.0 1608.0 \n", "27134 13 43.20 2.07445 42.5778 1531.0 2808.0 \n", "29970 2 128.08 6.99167 45.3167 1673.0 3754.0 \n", "30114 16 94.39 6.98333 45.4500 1785.0 3599.0 \n", "30127 2 82.72 7.05000 45.3667 1759.0 3642.0 " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "villes[villes[\"alt_min\"]>1500]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Analyser des données" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Compter le nombre de ligne" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dep 36700\n", "nom 36700\n", "cp 36700\n", "nb_hab_2010 36700\n", "nb_hab_1999 36700\n", "nb_hab_2012 36700\n", "dens 36700\n", "surf 36700\n", "long 36700\n", "lat 36700\n", "alt_min 36568\n", "alt_max 36568\n", "dtype: int64" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "villes.count()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Calculer une moyenne (ici la moyenne des habitants en 2010)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1768.0113079019075" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "villes[\"nb_hab_2010\"].mean()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Trouver un minimum (ici des habitants en 2010)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "villes[\"nb_hab_2010\"].min()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Trouver un maximum (ici des habitants en 2010)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2243833" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "villes[\"nb_hab_2010\"].max()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Trier les données\n", "\n", "- Trier en ordre croissant de la population en 2010" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
depnomcpnb_hab_2010nb_hab_1999nb_hab_2012denssurflonglatalt_minalt_max
2109655Bezonvaux5510000009.235.4675049.2367226.0367.0
2115555Louvemont-Côte-du-Poivre5510000008.255.3983449.2378214.0375.0
2103855Fleury-devant-Douaumont55100000010.275.4344549.1950227.0390.0
2105155Haumont-près-Samogneux55100000010.815.3525149.2728194.0355.0
2130055Beaumont-en-Verdunois5510000007.875.4077849.2587233.0372.0
.......................................
20496Nice06000-06100-06200-06300343304343123344900477371.927.2500043.70000.0520.0
1171831Toulouse31000-31100-31200-31300-31400-315004418023903014396003734118.301.4333343.6000115.0263.0
2815269Lyon69001-69002-69003-69004-69005-69006-69007-6900...4843444452744749001011747.874.8413945.7589162.0312.0
443913Marseille13001-13002-13003-13004-13005-13006-13007-1300...8507267974918514003535240.625.3763943.29670.0640.0
3043775Paris75001-75002-75003-75004-75005-75006-75007-7500...22438332125851221100021288105.402.3444548.860027.0127.0
\n", "

36700 rows × 12 columns

\n", "
" ], "text/plain": [ " dep nom \\\n", "21096 55 Bezonvaux \n", "21155 55 Louvemont-Côte-du-Poivre \n", "21038 55 Fleury-devant-Douaumont \n", "21051 55 Haumont-près-Samogneux \n", "21300 55 Beaumont-en-Verdunois \n", "... .. ... \n", "2049 6 Nice \n", "11718 31 Toulouse \n", "28152 69 Lyon \n", "4439 13 Marseille \n", "30437 75 Paris \n", "\n", " cp nb_hab_2010 \\\n", "21096 55100 0 \n", "21155 55100 0 \n", "21038 55100 0 \n", "21051 55100 0 \n", "21300 55100 0 \n", "... ... ... \n", "2049 06000-06100-06200-06300 343304 \n", "11718 31000-31100-31200-31300-31400-31500 441802 \n", "28152 69001-69002-69003-69004-69005-69006-69007-6900... 484344 \n", "4439 13001-13002-13003-13004-13005-13006-13007-1300... 850726 \n", "30437 75001-75002-75003-75004-75005-75006-75007-7500... 2243833 \n", "\n", " nb_hab_1999 nb_hab_2012 dens surf long lat alt_min \\\n", "21096 0 0 0 9.23 5.46750 49.2367 226.0 \n", "21155 0 0 0 8.25 5.39834 49.2378 214.0 \n", "21038 0 0 0 10.27 5.43445 49.1950 227.0 \n", "21051 0 0 0 10.81 5.35251 49.2728 194.0 \n", "21300 0 0 0 7.87 5.40778 49.2587 233.0 \n", "... ... ... ... ... ... ... ... \n", "2049 343123 344900 4773 71.92 7.25000 43.7000 0.0 \n", "11718 390301 439600 3734 118.30 1.43333 43.6000 115.0 \n", "28152 445274 474900 10117 47.87 4.84139 45.7589 162.0 \n", "4439 797491 851400 3535 240.62 5.37639 43.2967 0.0 \n", "30437 2125851 2211000 21288 105.40 2.34445 48.8600 27.0 \n", "\n", " alt_max \n", "21096 367.0 \n", "21155 375.0 \n", "21038 390.0 \n", "21051 355.0 \n", "21300 372.0 \n", "... ... \n", "2049 520.0 \n", "11718 263.0 \n", "28152 312.0 \n", "4439 640.0 \n", "30437 127.0 \n", "\n", "[36700 rows x 12 columns]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "villes.sort_values(by=\"nb_hab_2010\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Trie en ordre décroissant (ici de l'altitude)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
depnomcpnb_hab_2010nb_hab_1999nb_hab_2012denssurflonglatalt_minalt_max
3011473Val-d'Isère731501563162816001694.396.9833345.450001785.03599.0
3012773Bonneval-sur-Arc73480241239200282.727.0500045.366701759.03642.0
17985Saint-Véran5350257265300544.756.8666744.700001756.03175.0
2997073Bessans734803433103002128.086.9916745.316701673.03754.0
18475Molines-en-Queyras5350315322300553.626.8500044.733301625.03160.0
.......................................
36695976Sada9764010195101951019593310.9245.10470-12.84860NaNNaN
36696976Tsingoni9768010454104541045430034.7645.10700-12.78970NaNNaN
36697971Saint-Barthélemy9713389388938893837224.00-62.8333017.91670NaNNaN
36698971Saint-Martin9715036979369793697969553.2018.09130-63.08290NaNNaN
36699975Saint-Pierre-et-Miquelon9750060806080608025242.0046.710701.71819NaNNaN
\n", "

36700 rows × 12 columns

\n", "
" ], "text/plain": [ " dep nom cp nb_hab_2010 nb_hab_1999 \\\n", "30114 73 Val-d'Isère 73150 1563 1628 \n", "30127 73 Bonneval-sur-Arc 73480 241 239 \n", "1798 5 Saint-Véran 5350 257 265 \n", "29970 73 Bessans 73480 343 310 \n", "1847 5 Molines-en-Queyras 5350 315 322 \n", "... ... ... ... ... ... \n", "36695 976 Sada 97640 10195 10195 \n", "36696 976 Tsingoni 97680 10454 10454 \n", "36697 971 Saint-Barthélemy 97133 8938 8938 \n", "36698 971 Saint-Martin 97150 36979 36979 \n", "36699 975 Saint-Pierre-et-Miquelon 97500 6080 6080 \n", "\n", " nb_hab_2012 dens surf long lat alt_min alt_max \n", "30114 1600 16 94.39 6.98333 45.45000 1785.0 3599.0 \n", "30127 200 2 82.72 7.05000 45.36670 1759.0 3642.0 \n", "1798 300 5 44.75 6.86667 44.70000 1756.0 3175.0 \n", "29970 300 2 128.08 6.99167 45.31670 1673.0 3754.0 \n", "1847 300 5 53.62 6.85000 44.73330 1625.0 3160.0 \n", "... ... ... ... ... ... ... ... \n", "36695 10195 933 10.92 45.10470 -12.84860 NaN NaN \n", "36696 10454 300 34.76 45.10700 -12.78970 NaN NaN \n", "36697 8938 372 24.00 -62.83330 17.91670 NaN NaN \n", "36698 36979 695 53.20 18.09130 -63.08290 NaN NaN \n", "36699 6080 25 242.00 46.71070 1.71819 NaN NaN \n", "\n", "[36700 rows x 12 columns]" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "villes.sort_values(by=\"alt_min\", ascending=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Faire des opérations avec les données\n", "\n", "On pourrait vouloir calculer la différence entre la population en 2010 et en 2012 et ajouter le résultat dans une nouvelle colonne\n", "On peut le faire ainsi" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
depnomcpnb_hab_2010nb_hab_1999nb_hab_2012denssurflonglatalt_minalt_maxdiff_10_12
01Ozan1190618469500936.604.9166746.38330170.0205.0-118
11Cormoranche-sur-Saône1290105890310001079.854.8333346.23330168.0211.0-58
21Plagne113012983100206.205.7333346.18330560.0922.0-29
31Tossiat125014061111140013810.175.3166746.13330244.0501.0-6
41Pouillat12508858100146.235.4333346.33330333.0770.012
..........................................
36695976Sada9764010195101951019593310.9245.10470-12.84860NaNNaN0
36696976Tsingoni9768010454104541045430034.7645.10700-12.78970NaNNaN0
36697971Saint-Barthélemy9713389388938893837224.00-62.8333017.91670NaNNaN0
36698971Saint-Martin9715036979369793697969553.2018.09130-63.08290NaNNaN0
36699975Saint-Pierre-et-Miquelon9750060806080608025242.0046.710701.71819NaNNaN0
\n", "

36700 rows × 13 columns

\n", "
" ], "text/plain": [ " dep nom cp nb_hab_2010 nb_hab_1999 \\\n", "0 1 Ozan 1190 618 469 \n", "1 1 Cormoranche-sur-Saône 1290 1058 903 \n", "2 1 Plagne 1130 129 83 \n", "3 1 Tossiat 1250 1406 1111 \n", "4 1 Pouillat 1250 88 58 \n", "... ... ... ... ... ... \n", "36695 976 Sada 97640 10195 10195 \n", "36696 976 Tsingoni 97680 10454 10454 \n", "36697 971 Saint-Barthélemy 97133 8938 8938 \n", "36698 971 Saint-Martin 97150 36979 36979 \n", "36699 975 Saint-Pierre-et-Miquelon 97500 6080 6080 \n", "\n", " nb_hab_2012 dens surf long lat alt_min alt_max \\\n", "0 500 93 6.60 4.91667 46.38330 170.0 205.0 \n", "1 1000 107 9.85 4.83333 46.23330 168.0 211.0 \n", "2 100 20 6.20 5.73333 46.18330 560.0 922.0 \n", "3 1400 138 10.17 5.31667 46.13330 244.0 501.0 \n", "4 100 14 6.23 5.43333 46.33330 333.0 770.0 \n", "... ... ... ... ... ... ... ... \n", "36695 10195 933 10.92 45.10470 -12.84860 NaN NaN \n", "36696 10454 300 34.76 45.10700 -12.78970 NaN NaN \n", "36697 8938 372 24.00 -62.83330 17.91670 NaN NaN \n", "36698 36979 695 53.20 18.09130 -63.08290 NaN NaN \n", "36699 6080 25 242.00 46.71070 1.71819 NaN NaN \n", "\n", " diff_10_12 \n", "0 -118 \n", "1 -58 \n", "2 -29 \n", "3 -6 \n", "4 12 \n", "... ... \n", "36695 0 \n", "36696 0 \n", "36697 0 \n", "36698 0 \n", "36699 0 \n", "\n", "[36700 rows x 13 columns]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "villes[\"diff_10_12\"] = villes[\"nb_hab_2012\"] - villes[\"nb_hab_2010\"]\n", "villes" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.1" } }, "nbformat": 4, "nbformat_minor": 2 }