Script Python nettoyant des jeux de donnée
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
807 B

#!/usr/bin/env python
# coding: utf-8
# In[0]:
#Importer les librairies
import pandas as pd
# In[1]:
#Ouvrir un fichier CSV
# sep = ';' permet de separer les colonnes
df = pd.read_csv (r'/Users/marinegalanth/Desktop/inondation_bdd/bd_inondation/n_enjeu_rapport.csv', sep = ';')
print(df)
# In[2]:
#Conserver uniquement les colonnes utiles
df = df[["scenario","typ_inond", "id","id_tri"]]
# In[3]:
#Créer un dataframe
df = pd.DataFrame(df)
# In[4]:
#Modifier l'échelle du risque d'inondation de 1-4
df['scenario'] = df['scenario'].str.replace('01For','01Fai')
df['scenario'] = df['scenario'].str.replace('02Moy','02Mcc')
df['scenario'] = df['scenario'].str.replace('03Mcc','03Moy')
df['scenario'] = df['scenario'].str.replace('04Fai','04For')
# In[5]:
#Afficher le dataframe
df