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>
This commit is contained in:
Fabian Neumann 2024-07-29 11:56:14 +02:00 committed by GitHub
parent 936b490303
commit e9e0a0da20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 5 deletions

View File

@ -852,7 +852,7 @@ if __name__ == "__main__":
fuel_price = pd.read_csv( fuel_price = pd.read_csv(
snakemake.input.fuel_price, index_col=0, header=0, parse_dates=True 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: else:
fuel_price = None fuel_price = None

View File

@ -631,7 +631,7 @@ def calculate_co2_emissions(n, label, df):
weightings = n.snapshot_weightings.generators.mul( weightings = n.snapshot_weightings.generators.mul(
n.investment_period_weightings["years"] n.investment_period_weightings["years"]
.reindex(n.snapshots) .reindex(n.snapshots)
.fillna(method="bfill") .bfill()
.fillna(1.0), .fillna(1.0),
axis=0, axis=0,
) )

View File

@ -137,9 +137,7 @@ def add_emission_prices(n, emission_prices={"co2": 0.0}, exclude_co2=False):
def add_dynamic_emission_prices(n): def add_dynamic_emission_prices(n):
co2_price = pd.read_csv(snakemake.input.co2_price, index_col=0, parse_dates=True) 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[~co2_price.index.duplicated()]
co2_price = ( co2_price = co2_price.reindex(n.snapshots).ffill().bfill()
co2_price.reindex(n.snapshots).fillna(method="ffill").fillna(method="bfill")
)
emissions = ( emissions = (
n.generators.carrier.map(n.carriers.co2_emissions) / n.generators.efficiency n.generators.carrier.map(n.carriers.co2_emissions) / n.generators.efficiency