From 4135ef9c1f332ea2880fd55bf3b69e439ebaf551 Mon Sep 17 00:00:00 2001 From: "j.aschauer" Date: Thu, 23 Nov 2023 13:35:21 +0100 Subject: [PATCH] pass `parameter_to_change` to cost aggregation --- app/ptxboa_functions.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/ptxboa_functions.py b/app/ptxboa_functions.py index e88621a6..9c42cf55 100644 --- a/app/ptxboa_functions.py +++ b/app/ptxboa_functions.py @@ -87,15 +87,20 @@ def calculate_results_list( res_list.append(res_single) res_details = pd.concat(res_list) - return aggregate_costs(res_details) + return aggregate_costs(res_details, parameter_to_change) -def aggregate_costs(res_details: pd.DataFrame) -> pd.DataFrame: +def aggregate_costs( + res_details: pd.DataFrame, parameter_to_change: str +) -> pd.DataFrame: """Aggregate detailed costs.""" # Exclude levelized costs: res = res_details.loc[res_details["cost_type"] != "LC"] res = res.pivot_table( - index="region", columns="process_type", values="values", aggfunc="sum" + index=parameter_to_change, + columns="process_type", + values="values", + aggfunc="sum", ) # calculate total costs: res["Total"] = res.sum(axis=1)