pypsa-meets-earth / pypsa-earth-sec

GNU General Public License v3.0
18 stars 16 forks source link

TypeError in rule prepare_gas_network #327

Open doneachh opened 4 weeks ago

doneachh commented 4 weeks ago

Checklist

Describe the Bug

We receive a TypeError in rule prepare_gas_network, as we put two digits codes into the method three_2_two_digits_code (--> returns nan value) and try to add them with a string value afterwards.

Error Message

Traceback (most recent call last):
  File "/mnt/l/Git/Africa/pypsa-earth-sec/.snakemake/scripts/tmpvjh_6i9i.prepare_gas_network.py", line 924, in <module>
    pipelines["bus0"] = pipelines["bus0"].apply(
  File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/series.py", line 4924, in apply
    ).apply()
  File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/apply.py", line 1427, in apply
    return self.apply_standard()
  File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/apply.py", line 1507, in apply_standard
    mapped = obj._map_values(
  File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/base.py", line 921, in _map_values
    return algorithms.map_array(arr, mapper, na_action=na_action, convert=convert)
  File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/algorithms.py", line 1743, in map_array
    return lib.map_infer(values, mapper, convert=convert)
  File "lib.pyx", line 2972, in pandas._libs.lib.map_infer
  File "/mnt/l/Git/Africa/pypsa-earth-sec/.snakemake/scripts/tmpvjh_6i9i.prepare_gas_network.py", line 925, in <lambda>
    lambda id: three_2_two_digits_country(id[:3]) + id[3:]
TypeError: unsupported operand type(s) for +: 'float' and 'str'
[Sat Jun  1 22:51:19 2024]
Error in rule prepare_gas_network:
    jobid: 25
    input: /mnt/l/Git/Africa/pypsa-earth-sec/pypsa-earth/resources/bus_regions/regions_onshore_elec_s_165.geojson
    output: resources/gas_networks/gas_network_elec_s_165.csv, resources/gas_networks/existing_gas_pipelines__165.png, resources/gas_networks/clustered_gas_pipelines__165.png

RuleException:
CalledProcessError in file /mnt/l/Git/Africa/pypsa-earth-sec/Snakefile, line 158:
Command 'set -euo pipefail;  /home/aca39878/anaconda3/envs/pypsa-earth/bin/python3.10 /mnt/l/Git/Africa/pypsa-earth-sec/.snakemake/scripts/tmpvjh_6i9i.prepare_gas_network.py' returned non-zero exit status 1.
  File "/mnt/l/Git/Africa/pypsa-earth-sec/Snakefile", line 158, in __rule_prepare_gas_network
  File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/concurrent/futures/thread.py", line 58, in run
Removing output files of failed job prepare_gas_network since they might be corrupted:
resources/gas_networks/existing_gas_pipelines__165.png
Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message