simplify if-else expression
This commit is contained in:
parent
33305f9761
commit
e12cad2789
@ -435,20 +435,20 @@ def add_heating_capacities_installed_before_baseyear(
|
||||
|
||||
# split existing capacities between residential and services
|
||||
# proportional to energy demand
|
||||
p_set_sum = n.loads_t.p_set.sum()
|
||||
ratio_residential = pd.Series(
|
||||
[
|
||||
(
|
||||
n.loads_t.p_set.sum()[f"{node} residential rural heat"]
|
||||
p_set_sum[f"{node} residential rural heat"]
|
||||
/ (
|
||||
n.loads_t.p_set.sum()[f"{node} residential rural heat"]
|
||||
+ n.loads_t.p_set.sum()[f"{node} services rural heat"]
|
||||
p_set_sum[f"{node} residential rural heat"]
|
||||
+ p_set_sum[f"{node} services rural heat"]
|
||||
)
|
||||
)
|
||||
# if rural heating demand for one of the nodes doesn't exist,
|
||||
# then columns were dropped before and heating demand share should be 0.0
|
||||
if (f"{node} residential rural heat" in n.loads_t.p_set.sum().index)
|
||||
& (f"{node} services rural heat" in n.loads_t.p_set.sum().index)
|
||||
else 0.0
|
||||
if all(f"{node} {service} rural heat" in p_set_sum.index for service in ["residential", "services"])
|
||||
else 0.
|
||||
for node in nodal_df.index
|
||||
],
|
||||
index=nodal_df.index,
|
||||
|
Loading…
Reference in New Issue
Block a user