Address pandas deprecation warnings in prepare_perfect_foresight

This commit is contained in:
Koen van Greevenbroek 2024-02-06 09:39:11 +00:00
parent 7fbb605134
commit 73b80ebab3

View File

@ -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