[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] 2024-07-19 08:21:07 +00:00
parent 4c46c57fec
commit 086d46cdb4
2 changed files with 9 additions and 12 deletions

View File

@ -1103,10 +1103,12 @@ def build_transport_data(
transport_data = pd.concat([transport_data, swiss_cars]).sort_index() transport_data = pd.concat([transport_data, swiss_cars]).sort_index()
transport_data.rename(columns={"passenger cars": "number cars"}, inplace=True) transport_data.rename(columns={"passenger cars": "number cars"}, inplace=True)
# clean up dataframe # clean up dataframe
years = np.arange(2000, 2022) years = np.arange(2000, 2022)
transport_data = transport_data[transport_data.index.get_level_values(1).isin(years)] transport_data = transport_data[
transport_data.index.get_level_values(1).isin(years)
]
missing = transport_data.index[transport_data["number cars"].isna()] missing = transport_data.index[transport_data["number cars"].isna()]
if not missing.empty: if not missing.empty:

View File

@ -10,19 +10,18 @@ import logging
import os import os
import zipfile import zipfile
from pathlib import Path from pathlib import Path
from _helpers import configure_logging, progress_retrieve, set_scenario_config
from _helpers import configure_logging, progress_retrieve, set_scenario_config
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# Define the base URL # Define the base URL
url_jrc = ( url_jrc = "https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/JRC-IDEES/JRC-IDEES-2021_v1/JRC-IDEES-2021.zip"
"https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/JRC-IDEES/JRC-IDEES-2021_v1/JRC-IDEES-2021.zip"
)
if __name__ == "__main__": if __name__ == "__main__":
if "snakemake" not in globals(): if "snakemake" not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake("retrieve_jrc_idees") snakemake = mock_snakemake("retrieve_jrc_idees")
rootpath = ".." rootpath = ".."
else: else:
@ -36,16 +35,12 @@ if __name__ == "__main__":
to_fn_zp = to_fn + ".zip" to_fn_zp = to_fn + ".zip"
# download .zip file # download .zip file
logger.info( logger.info(f"Downloading JRC IDEES from {url_jrc}.")
f"Downloading JRC IDEES from {url_jrc}."
)
progress_retrieve(url_jrc, to_fn_zp, disable=disable_progress) progress_retrieve(url_jrc, to_fn_zp, disable=disable_progress)
# extract # extract
logger.info("Extracting JRC IDEES data.") logger.info("Extracting JRC IDEES data.")
with zipfile.ZipFile(to_fn_zp, "r") as zip_ref: with zipfile.ZipFile(to_fn_zp, "r") as zip_ref:
zip_ref.extractall(to_fn) zip_ref.extractall(to_fn)
logger.info(f"JRC IDEES data available in '{to_fn}'.") logger.info(f"JRC IDEES data available in '{to_fn}'.")