UPDATE correction error jointure auteurs-params

This commit is contained in:
Colas Geier 2021-12-21 17:06:38 +01:00
parent a3e303e1b7
commit c262045532

View File

@ -253,10 +253,23 @@ def _get_relation_autor2(df, relation_tab, schema, id_df, id_relation, id_rela_a
right_id = id_relation)
aut = get_auteur2()[['nom_prenom']]
df[id_rela_auth] = df[id_rela_auth].astype(float)
df = df.merge(aut,how='left', left_on=id_rela_auth, right_index=True)
aut_df = df[id_rela_auth].str.split(' & ',expand = True)
aut_df.replace([*aut.index.astype(str)],[*aut.nom_prenom], inplace=True)
lst_col = aut_df.columns.drop(0)
aut_df[id_rela_auth] = aut_df[0]
for col in lst_col:
aut_df.loc[~aut_df[col].isna(),id_rela_auth] = aut_df.loc[~aut_df[col].isna(),id_rela_auth] + \
' & ' + aut_df.loc[~aut_df[col].isna(),col]
aut_df.drop(columns=[0,*lst_col], inplace=True)
aut_df.columns = [id_rela_auth + '_tmp']
df = df.merge(aut_df,how='left', left_index=True, right_index=True)
df[id_rela_auth] = df[id_rela_auth+'_tmp']
del df[id_rela_auth+'_tmp']
# df[id_rela_auth] = df[id_rela_auth].astype(float)
# df = df.merge(aut,how='left', left_on=id_rela_auth, right_index=True)
# df = _merge_author(df=df, col_aut=id_rela_auth, on_index=True)
df.rename(columns={'auteur': 'auteur'+suffixe}, inplace=True)
df.rename(columns={id_rela_auth: 'auteur'+suffixe}, inplace=True)
return df