From e9e0a0da2064a242b0d731dc2218de0e6cbca190 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Mon, 29 Jul 2024 11:56:14 +0200 Subject: [PATCH] address fillna(method='{b|f}fill') deprecation (#1181) * address fillne(method='{b|f}fill') deprecation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- scripts/add_electricity.py | 2 +- scripts/make_summary_perfect.py | 2 +- scripts/prepare_network.py | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 17e030b4..49510953 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -852,7 +852,7 @@ if __name__ == "__main__": fuel_price = pd.read_csv( snakemake.input.fuel_price, index_col=0, header=0, parse_dates=True ) - fuel_price = fuel_price.reindex(n.snapshots).fillna(method="ffill") + fuel_price = fuel_price.reindex(n.snapshots).ffill() else: fuel_price = None diff --git a/scripts/make_summary_perfect.py b/scripts/make_summary_perfect.py index 76bd4ad0..8e56e5d4 100644 --- a/scripts/make_summary_perfect.py +++ b/scripts/make_summary_perfect.py @@ -631,7 +631,7 @@ def calculate_co2_emissions(n, label, df): weightings = n.snapshot_weightings.generators.mul( n.investment_period_weightings["years"] .reindex(n.snapshots) - .fillna(method="bfill") + .bfill() .fillna(1.0), axis=0, ) diff --git a/scripts/prepare_network.py b/scripts/prepare_network.py index 00cb00bf..382e633d 100755 --- a/scripts/prepare_network.py +++ b/scripts/prepare_network.py @@ -137,9 +137,7 @@ def add_emission_prices(n, emission_prices={"co2": 0.0}, exclude_co2=False): def add_dynamic_emission_prices(n): co2_price = pd.read_csv(snakemake.input.co2_price, index_col=0, parse_dates=True) co2_price = co2_price[~co2_price.index.duplicated()] - co2_price = ( - co2_price.reindex(n.snapshots).fillna(method="ffill").fillna(method="bfill") - ) + co2_price = co2_price.reindex(n.snapshots).ffill().bfill() emissions = ( n.generators.carrier.map(n.carriers.co2_emissions) / n.generators.efficiency