diff --git a/chargement_propilot.py b/chargement_propilot.py index 2a134c8b..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): @@ -212,11 +215,11 @@ 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_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_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_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', 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))