m_galanth
2 years ago
1 changed files with 0 additions and 279 deletions
@ -1,279 +0,0 @@ |
|||
{ |
|||
"cells": [ |
|||
{ |
|||
"cell_type": "code", |
|||
"execution_count": 1, |
|||
"id": "218a3acb", |
|||
"metadata": {}, |
|||
"outputs": [], |
|||
"source": [ |
|||
"#Importer les librairies \n", |
|||
"import pandas as pd" |
|||
] |
|||
}, |
|||
{ |
|||
"cell_type": "code", |
|||
"execution_count": 2, |
|||
"id": "c27a317c", |
|||
"metadata": {}, |
|||
"outputs": [ |
|||
{ |
|||
"name": "stdout", |
|||
"output_type": "stream", |
|||
"text": [ |
|||
" Code Postal / CEDEX Libellé Code INSEE Type de code \\\n", |
|||
"0 73350 CHAMPAGNY EN VANOISE 73071 Code Postal \n", |
|||
"1 67530 OTTROTT 67368 Code Postal \n", |
|||
"2 35190 ST DOMINEUC 35265 Code Postal \n", |
|||
"3 39120 PESEUX 39412 Code Postal \n", |
|||
"4 39200 LA RIXOUSE 39460 Code Postal \n", |
|||
"... ... ... ... ... \n", |
|||
"50598 97479 ST DENIS CEDEX 97411 Code CEDEX \n", |
|||
"50599 97489 ST DENIS CEDEX 97411 Code CEDEX \n", |
|||
"50600 97707 ST DENIS CEDEX 9 97411 Code CEDEX \n", |
|||
"50601 97717 ST DENIS CEDEX 9 97411 Code CEDEX \n", |
|||
"50602 97751 ST PIERRE CEDEX 97416 Code CEDEX \n", |
|||
"\n", |
|||
" Nom de la commune Nom du département \\\n", |
|||
"0 Champagny-en-Vanoise SAVOIE \n", |
|||
"1 Ottrott BAS-RHIN \n", |
|||
"2 Saint-Domineuc ILLE-ET-VILAINE \n", |
|||
"3 Peseux JURA \n", |
|||
"4 La Rixouse JURA \n", |
|||
"... ... ... \n", |
|||
"50598 Saint-Denis LA REUNION \n", |
|||
"50599 Saint-Denis LA REUNION \n", |
|||
"50600 Saint-Denis LA REUNION \n", |
|||
"50601 Saint-Denis LA REUNION \n", |
|||
"50602 Saint-Pierre LA REUNION \n", |
|||
"\n", |
|||
" NOM EPCI \\\n", |
|||
"0 CC Val Vanoise \n", |
|||
"1 CC des Portes de Rosheim \n", |
|||
"2 CC Bretagne Romantique \n", |
|||
"3 CA du Grand Dole \n", |
|||
"4 CC Haut-Jura Saint-Claude \n", |
|||
"... ... \n", |
|||
"50598 CA Intercommunale du Nord de la Réunion (Cinor) \n", |
|||
"50599 CA Intercommunale du Nord de la Réunion (Cinor) \n", |
|||
"50600 CA Intercommunale du Nord de la Réunion (Cinor) \n", |
|||
"50601 CA Intercommunale du Nord de la Réunion (Cinor) \n", |
|||
"50602 CA Civis (Communauté Intercommunale des Villes... \n", |
|||
"\n", |
|||
" Nom de la région \n", |
|||
"0 AUVERGNE-RHONE-ALPES \n", |
|||
"1 GRAND EST \n", |
|||
"2 BRETAGNE \n", |
|||
"3 BOURGOGNE-FRANCHE-COMTE \n", |
|||
"4 BOURGOGNE-FRANCHE-COMTE \n", |
|||
"... ... \n", |
|||
"50598 LA REUNION \n", |
|||
"50599 LA REUNION \n", |
|||
"50600 LA REUNION \n", |
|||
"50601 LA REUNION \n", |
|||
"50602 LA REUNION \n", |
|||
"\n", |
|||
"[50603 rows x 8 columns]\n" |
|||
] |
|||
} |
|||
], |
|||
"source": [ |
|||
"#Ouvrir un fichier CSV\n", |
|||
"#Ajout d'un séparateur des colonnes \n", |
|||
"df = pd.read_csv (r'/Users/marinegalanth/Desktop/inondation_bdd/bd_inondation/cedex.csv',sep = ';')\n", |
|||
"print(df)" |
|||
] |
|||
}, |
|||
{ |
|||
"cell_type": "code", |
|||
"execution_count": 3, |
|||
"id": "415f6eb1", |
|||
"metadata": {}, |
|||
"outputs": [], |
|||
"source": [ |
|||
"#Renommer les colonnes sélectionnées \n", |
|||
"df = df.rename(columns={'Code INSEE': 'codepostal', 'Libellé': 'libelle', 'Code Postal / CEDEX': 'cedex'})" |
|||
] |
|||
}, |
|||
{ |
|||
"cell_type": "code", |
|||
"execution_count": 4, |
|||
"id": "abc56e1a", |
|||
"metadata": {}, |
|||
"outputs": [], |
|||
"source": [ |
|||
"df=df[[\"codepostal\",\"libelle\",\"cedex\"]]" |
|||
] |
|||
}, |
|||
{ |
|||
"cell_type": "code", |
|||
"execution_count": 5, |
|||
"id": "6b6f3a1c", |
|||
"metadata": {}, |
|||
"outputs": [], |
|||
"source": [ |
|||
"#Créer un dataframe\n", |
|||
"df1 = pd.DataFrame(df)" |
|||
] |
|||
}, |
|||
{ |
|||
"cell_type": "code", |
|||
"execution_count": 6, |
|||
"id": "ae19dadc", |
|||
"metadata": {}, |
|||
"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 th {\n", |
|||
" text-align: right;\n", |
|||
" }\n", |
|||
"</style>\n", |
|||
"<table border=\"1\" class=\"dataframe\">\n", |
|||
" <thead>\n", |
|||
" <tr style=\"text-align: right;\">\n", |
|||
" <th></th>\n", |
|||
" <th>codepostal</th>\n", |
|||
" <th>libelle</th>\n", |
|||
" <th>cedex</th>\n", |
|||
" </tr>\n", |
|||
" </thead>\n", |
|||
" <tbody>\n", |
|||
" <tr>\n", |
|||
" <th>0</th>\n", |
|||
" <td>73071</td>\n", |
|||
" <td>CHAMPAGNY EN VANOISE</td>\n", |
|||
" <td>73350</td>\n", |
|||
" </tr>\n", |
|||
" <tr>\n", |
|||
" <th>1</th>\n", |
|||
" <td>67368</td>\n", |
|||
" <td>OTTROTT</td>\n", |
|||
" <td>67530</td>\n", |
|||
" </tr>\n", |
|||
" <tr>\n", |
|||
" <th>2</th>\n", |
|||
" <td>35265</td>\n", |
|||
" <td>ST DOMINEUC</td>\n", |
|||
" <td>35190</td>\n", |
|||
" </tr>\n", |
|||
" <tr>\n", |
|||
" <th>3</th>\n", |
|||
" <td>39412</td>\n", |
|||
" <td>PESEUX</td>\n", |
|||
" <td>39120</td>\n", |
|||
" </tr>\n", |
|||
" <tr>\n", |
|||
" <th>4</th>\n", |
|||
" <td>39460</td>\n", |
|||
" <td>LA RIXOUSE</td>\n", |
|||
" <td>39200</td>\n", |
|||
" </tr>\n", |
|||
" <tr>\n", |
|||
" <th>...</th>\n", |
|||
" <td>...</td>\n", |
|||
" <td>...</td>\n", |
|||
" <td>...</td>\n", |
|||
" </tr>\n", |
|||
" <tr>\n", |
|||
" <th>50598</th>\n", |
|||
" <td>97411</td>\n", |
|||
" <td>ST DENIS CEDEX</td>\n", |
|||
" <td>97479</td>\n", |
|||
" </tr>\n", |
|||
" <tr>\n", |
|||
" <th>50599</th>\n", |
|||
" <td>97411</td>\n", |
|||
" <td>ST DENIS CEDEX</td>\n", |
|||
" <td>97489</td>\n", |
|||
" </tr>\n", |
|||
" <tr>\n", |
|||
" <th>50600</th>\n", |
|||
" <td>97411</td>\n", |
|||
" <td>ST DENIS CEDEX 9</td>\n", |
|||
" <td>97707</td>\n", |
|||
" </tr>\n", |
|||
" <tr>\n", |
|||
" <th>50601</th>\n", |
|||
" <td>97411</td>\n", |
|||
" <td>ST DENIS CEDEX 9</td>\n", |
|||
" <td>97717</td>\n", |
|||
" </tr>\n", |
|||
" <tr>\n", |
|||
" <th>50602</th>\n", |
|||
" <td>97416</td>\n", |
|||
" <td>ST PIERRE CEDEX</td>\n", |
|||
" <td>97751</td>\n", |
|||
" </tr>\n", |
|||
" </tbody>\n", |
|||
"</table>\n", |
|||
"<p>50603 rows × 3 columns</p>\n", |
|||
"</div>" |
|||
], |
|||
"text/plain": [ |
|||
" codepostal libelle cedex\n", |
|||
"0 73071 CHAMPAGNY EN VANOISE 73350\n", |
|||
"1 67368 OTTROTT 67530\n", |
|||
"2 35265 ST DOMINEUC 35190\n", |
|||
"3 39412 PESEUX 39120\n", |
|||
"4 39460 LA RIXOUSE 39200\n", |
|||
"... ... ... ...\n", |
|||
"50598 97411 ST DENIS CEDEX 97479\n", |
|||
"50599 97411 ST DENIS CEDEX 97489\n", |
|||
"50600 97411 ST DENIS CEDEX 9 97707\n", |
|||
"50601 97411 ST DENIS CEDEX 9 97717\n", |
|||
"50602 97416 ST PIERRE CEDEX 97751\n", |
|||
"\n", |
|||
"[50603 rows x 3 columns]" |
|||
] |
|||
}, |
|||
"execution_count": 6, |
|||
"metadata": {}, |
|||
"output_type": "execute_result" |
|||
} |
|||
], |
|||
"source": [ |
|||
"df1" |
|||
] |
|||
}, |
|||
{ |
|||
"cell_type": "code", |
|||
"execution_count": null, |
|||
"id": "5121a02a", |
|||
"metadata": {}, |
|||
"outputs": [], |
|||
"source": [] |
|||
} |
|||
], |
|||
"metadata": { |
|||
"kernelspec": { |
|||
"display_name": "Python 3 (ipykernel)", |
|||
"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.9.7" |
|||
} |
|||
}, |
|||
"nbformat": 4, |
|||
"nbformat_minor": 5 |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue