[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2023-10-11 12:27:27 +00:00
parent 43e20a26e6
commit 230c1a327c
2 changed files with 16 additions and 16 deletions

View File

@ -38,9 +38,9 @@ if config["enable"]["retrieve"] and config["enable"].get("retrieve_databundle",
script:
"../scripts/retrieve_databundle.py"
if config["enable"].get("retrieve_irena", True):
datafiles=[
if config["enable"].get("retrieve_irena", True):
datafiles = [
"offwind_capacity_IRENA.csv",
"onwind_capacity_IRENA.csv",
"solar_capacity_IRENA.csv",

View File

@ -3,7 +3,6 @@
# SPDX-FileCopyrightText: : 2017-2023 The PyPSA-Eur Authors
#
# SPDX-License-Identifier: MIT
"""
This rule downloads the existing capacities from `IRENASTAT <https://www.irena.org/Data/Downloads/IRENASTAT>`_ and extracts it in the ``data/existing_capacities`` sub-directory.
@ -27,7 +26,6 @@ This rule downloads the existing capacities from `IRENASTAT <https://www.irena.o
import logging
import pandas as pd
from _helpers import configure_logging
logger = logging.getLogger(__name__)
@ -74,7 +72,6 @@ REGIONS_DICT = {
"Bosnia and Herzegovina": "Bosnia Herzg",
"Netherlands (Kingdom of the)": "Netherlands",
"United Kingdom of Great Britain and Northern Ireland (the)": "UK",
}
if __name__ == "__main__":
@ -84,23 +81,26 @@ if __name__ == "__main__":
snakemake = mock_snakemake("retrieve_irena")
configure_logging(snakemake)
irena_raw = pd.read_csv("https://pxweb.irena.org:443/sq/99e64b12-fe03-4a7b-92ea-a22cc3713b92",
skiprows=2, index_col=[0, 1, 3], encoding="latin-1")
irena_raw = pd.read_csv(
"https://pxweb.irena.org:443/sq/99e64b12-fe03-4a7b-92ea-a22cc3713b92",
skiprows=2,
index_col=[0, 1, 3],
encoding="latin-1",
)
var = "Installed electricity capacity (MW)"
irena = (
irena_raw[var]
.unstack(level=2)
.reset_index(level=1)
.replace(0, "")
)
irena = irena_raw[var].unstack(level=2).reset_index(level=1).replace(0, "")
irena = irena[irena.index.isin(REGIONS)]
irena.rename(index=REGIONS_DICT, inplace=True)
df_offwind = irena[irena.Technology.str.contains("Offshore")].drop(columns=['Technology'])
df_onwind = irena[irena.Technology.str.contains("Onshore")].drop(columns=['Technology'])
df_pv = irena[irena.Technology.str.contains("Solar")].drop(columns=['Technology'])
df_offwind = irena[irena.Technology.str.contains("Offshore")].drop(
columns=["Technology"]
)
df_onwind = irena[irena.Technology.str.contains("Onshore")].drop(
columns=["Technology"]
)
df_pv = irena[irena.Technology.str.contains("Solar")].drop(columns=["Technology"])
df_offwind.to_csv(snakemake.output[0])
df_onwind.to_csv(snakemake.output[1])