From f02cd92db88b3ee21df7028a6d9f2fe49aa4394b Mon Sep 17 00:00:00 2001 From: Guillaume <72020675+kaa-serpent@users.noreply.github.com> Date: Tue, 9 May 2023 14:53:57 +0200 Subject: [PATCH 1/3] merge suffixes when col ar present in both df --- chargement_propilot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chargement_propilot.py b/chargement_propilot.py index 2a134c8b..97d00a4c 100644 --- a/chargement_propilot.py +++ b/chargement_propilot.py @@ -213,10 +213,10 @@ def load_propilot(): df = (df_dict["fact_financials"] .merge(df_dict["dim_tree_nodes"], left_on="tree_node_id", right_on="tree_node_id") - .merge(df_dict["dim_effects"], left_on="effect_id", right_on="effect_id") - .merge(df_dict["dim_states"], left_on="state_id", right_on="state_id") + .merge(df_dict["dim_effects"], left_on="effect_id", right_on="effect_id", suffixes=('', '_right')) + .merge(df_dict["dim_states"], left_on="state_id", right_on="state_id", suffixes=('', '_right')) .merge(df_dict["dim_period"], left_on="period_id", right_on="period_id", how='left') - .merge(df_dict["dim_structures"], left_on="structure_id", right_on="structure_id")) + .merge(df_dict["dim_structures"], left_on="structure_id", right_on="structure_id", suffixes=('', '_right'))) df['dep_code'] = df['tree_node_code'].apply(lambda x: extract_dep_code(x)) From 8a0450921d82cff818a5268283a0d6a143908713 Mon Sep 17 00:00:00 2001 From: Guillaume <72020675+kaa-serpent@users.noreply.github.com> Date: Tue, 9 May 2023 14:57:02 +0200 Subject: [PATCH 2/3] suffix on all merge --- chargement_propilot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chargement_propilot.py b/chargement_propilot.py index 97d00a4c..9de966d9 100644 --- a/chargement_propilot.py +++ b/chargement_propilot.py @@ -212,10 +212,10 @@ def load_propilot(): ~df_dict["fact_financials"].financials_cumulated_amount.isna()] df = (df_dict["fact_financials"] - .merge(df_dict["dim_tree_nodes"], left_on="tree_node_id", right_on="tree_node_id") + .merge(df_dict["dim_tree_nodes"], left_on="tree_node_id", right_on="tree_node_id", suffixes=('', '_right')) .merge(df_dict["dim_effects"], left_on="effect_id", right_on="effect_id", suffixes=('', '_right')) .merge(df_dict["dim_states"], left_on="state_id", right_on="state_id", suffixes=('', '_right')) - .merge(df_dict["dim_period"], left_on="period_id", right_on="period_id", how='left') + .merge(df_dict["dim_period"], left_on="period_id", right_on="period_id", how='left', suffixes=('', '_right')) .merge(df_dict["dim_structures"], left_on="structure_id", right_on="structure_id", suffixes=('', '_right'))) df['dep_code'] = df['tree_node_code'].apply(lambda x: extract_dep_code(x)) From 1a6d669f14e7d5363da6bc1e39f6836cd10c7fcd Mon Sep 17 00:00:00 2001 From: Guillaume <72020675+kaa-serpent@users.noreply.github.com> Date: Tue, 9 May 2023 15:06:13 +0200 Subject: [PATCH 3/3] recup date fix float --- chargement_propilot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/chargement_propilot.py b/chargement_propilot.py index 9de966d9..ebbd89b3 100644 --- a/chargement_propilot.py +++ b/chargement_propilot.py @@ -161,9 +161,12 @@ def get_df_sum_indicator(df_dep: pd.DataFrame, def recup_date(string: str) -> str: """ - retire les informations inutile présente dans la date '2020-12-31T00:00:00.0000000' -> '2020-12-31' + retire les informations inutile présente dans la date '2020-12-31T00:00:00.0000000' -> '2020-12-31' seulement pour les str """ - return string[:10] + if isinstance(string, str): + return string[:10] + else: + return string def mkdir_ifnotexist(path: str):