From 9e28a22f2037911fcbe7796ecee26dd013496db9 Mon Sep 17 00:00:00 2001 From: nesnoj Date: Thu, 25 Apr 2024 17:23:41 +0200 Subject: [PATCH] Insert missing years for temporal stats on wind and pv --- .../store/datasets/bnetza_mastr_pv_ground_region/create.smk | 5 +++++ apipe/store/datasets/bnetza_mastr_pv_roof_region/create.smk | 5 +++++ apipe/store/datasets/bnetza_mastr_wind_region/create.smk | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/apipe/store/datasets/bnetza_mastr_pv_ground_region/create.smk b/apipe/store/datasets/bnetza_mastr_pv_ground_region/create.smk index 3def521..b5073af 100644 --- a/apipe/store/datasets/bnetza_mastr_pv_ground_region/create.smk +++ b/apipe/store/datasets/bnetza_mastr_pv_ground_region/create.smk @@ -103,5 +103,10 @@ rule create_development_over_time: df_combined["capacity_net"] = ( df_combined["capacity_net"].div(1e3).round(1) ) + # Fill missing years by using values from year before + df_combined = df_combined.set_index("year").reindex( + range(df_combined["year"].min(), df_combined["year"].max() + 1) + ).ffill().reset_index() + df_combined["year"] = df_combined["year"].astype(int) df_combined.to_csv(output[0], index=False) diff --git a/apipe/store/datasets/bnetza_mastr_pv_roof_region/create.smk b/apipe/store/datasets/bnetza_mastr_pv_roof_region/create.smk index 1fb3e6a..64b4349 100644 --- a/apipe/store/datasets/bnetza_mastr_pv_roof_region/create.smk +++ b/apipe/store/datasets/bnetza_mastr_pv_roof_region/create.smk @@ -101,5 +101,10 @@ rule create_development_over_time: df_combined["capacity_net"] = ( df_combined["capacity_net"].div(1e3).round(1) ) + # Fill missing years by using values from year before + df_combined = df_combined.set_index("year").reindex( + range(df_combined["year"].min(), df_combined["year"].max() + 1) + ).ffill().reset_index() + df_combined["year"] = df_combined["year"].astype(int) df_combined.to_csv(output[0], index=False) diff --git a/apipe/store/datasets/bnetza_mastr_wind_region/create.smk b/apipe/store/datasets/bnetza_mastr_wind_region/create.smk index f556809..725606c 100644 --- a/apipe/store/datasets/bnetza_mastr_wind_region/create.smk +++ b/apipe/store/datasets/bnetza_mastr_wind_region/create.smk @@ -94,5 +94,10 @@ rule create_development_over_time: df_combined["capacity_net"] = ( df_combined["capacity_net"].div(1e3).round(1) ) + # Fill missing years by using values from year before + df_combined = df_combined.set_index("year").reindex( + range(df_combined["year"].min(), df_combined["year"].max() + 1) + ).ffill().reset_index() + df_combined["year"] = df_combined["year"].astype(int) df_combined.to_csv(output[0], index=False)