From e423945e7d709d1cb59d85caab4b306bd752c045 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Wed, 3 Jan 2024 10:54:53 +0100 Subject: [PATCH] gas_input: ensure all columns exist even if column empty --- scripts/build_gas_input_locations.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/build_gas_input_locations.py b/scripts/build_gas_input_locations.py index 2f967c75..9ad3760d 100644 --- a/scripts/build_gas_input_locations.py +++ b/scripts/build_gas_input_locations.py @@ -161,8 +161,12 @@ if __name__ == "__main__": gas_input_nodes.to_file(snakemake.output.gas_input_nodes, driver="GeoJSON") + ensure_columns = ["lng", "pipeline", "production", "storage"] gas_input_nodes_s = ( - gas_input_nodes.groupby(["bus", "type"])["capacity"].sum().unstack() + gas_input_nodes.groupby(["bus", "type"])["capacity"] + .sum() + .unstack() + .reindex(columns=ensure_columns) ) gas_input_nodes_s.columns.name = "capacity"