From 73b80ebab38cf275d3410fb5918e37061df452e4 Mon Sep 17 00:00:00 2001 From: Koen van Greevenbroek Date: Tue, 6 Feb 2024 09:39:11 +0000 Subject: [PATCH] Address pandas deprecation warnings in `prepare_perfect_foresight` --- scripts/prepare_perfect_foresight.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/prepare_perfect_foresight.py b/scripts/prepare_perfect_foresight.py index 3d72cd8c..467682a9 100644 --- a/scripts/prepare_perfect_foresight.py +++ b/scripts/prepare_perfect_foresight.py @@ -56,7 +56,9 @@ def get_investment_weighting(time_weighting, r=0.01): end = time_weighting.cumsum() start = time_weighting.cumsum().shift().fillna(0) return pd.concat([start, end], axis=1).apply( - lambda x: sum(get_social_discount(t, r) for t in range(int(x[0]), int(x[1]))), + lambda x: sum( + get_social_discount(t, r) for t in range(int(x.iloc[0]), int(x.iloc[1])) + ), axis=1, ) @@ -188,7 +190,7 @@ def concat_networks(years): pnl = getattr(n, component.list_name + "_t") for k in iterkeys(component.pnl): pnl_year = component.pnl[k].copy().reindex(snapshots, level=1) - if pnl_year.empty and ~(component.name == "Load" and k == "p_set"): + if pnl_year.empty and (not (component.name == "Load" and k == "p_set")): continue if component.name == "Load": static_load = network.loads.loc[network.loads.p_set != 0] @@ -398,7 +400,7 @@ def add_H2_boilers(n): c = "Link" logger.info("Add H2 boilers.") # existing gas boilers - mask = n.links.carrier.str.contains("gas boiler") & ~n.links.p_nom_extendable + mask = n.links.carrier.str.contains("gas boiler") & (not n.links.p_nom_extendable) gas_i = n.links[mask].index df = n.links.loc[gas_i] # adjust bus 0