23 lines
565 B
Python
23 lines
565 B
Python
import pandas as pd
|
|
from os import path
|
|
from pycen import con_gn
|
|
|
|
# PARAMS
|
|
PATH = '/home/cgeier/Téléchargements'
|
|
file = 'donnees_ebms_platiere2025.csv'
|
|
|
|
# READ DATA
|
|
tax = pd.read_sql('SELECT * FROM taxonomie.taxref where cd_nom=cd_ref',con_gn)
|
|
df = pd.read_csv(path.join(PATH,file),index_col=0)
|
|
|
|
# MAKE DICTIONARY
|
|
dic_tax_lbno = dict(zip(tax.lb_nom,tax.cd_ref.astype(str)))
|
|
|
|
# MANIP DATA
|
|
df['cd_ref'] = df['Preferred Species Name'].copy()
|
|
df.replace({'cd_ref':dic_tax_lbno},inplace=True)
|
|
|
|
df['cd_ref'] = df['cd_ref'].astype(int)
|
|
|
|
df.to_csv(path.join(PATH,file))
|