|
@ -0,0 +1,59 @@ |
|
|
|
|
|
#!/usr/bin/env python |
|
|
|
|
|
# coding: utf-8 |
|
|
|
|
|
|
|
|
|
|
|
# In[8]: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Importer les librairies |
|
|
|
|
|
import pandas as pd |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# In[9]: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Ouvrir un fichier CSV |
|
|
|
|
|
df = pd.read_csv (r'/Users/marinegalanth/Desktop/inondation_bdd/bd_inondation/_n_tri_s.csv') |
|
|
|
|
|
print(df) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# In[10]: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Renommer les colonnes sélectionnées |
|
|
|
|
|
df = df.rename(columns={'nom,C,229': 'nomcommune','id_tri,C,80': 'id_tri'}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# In[11]: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Supprimer les 8 premiers caractères des valeurs de la colonne id_tri |
|
|
|
|
|
#Supprimer les caractères inutiles suivant : FRM_TRI_ |
|
|
|
|
|
df["id_tri"]=df["id_tri"].str[8:] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# In[14]: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Conserver uniquement les colonnes utiles |
|
|
|
|
|
df = df[["nomcommune","id_tri"]] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# In[15]: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Créer un dataframe |
|
|
|
|
|
df = pd.DataFrame(df) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# In[16]: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Afficher le dataframe |
|
|
|
|
|
df |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# In[ ]: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|