PyPSA/pypsa-eur

cluster gas network not working for some nodes

millingermarkus opened this issue · 1 comments

Checklist

  • I am using the current master branch or the latest release. Please indicate.
  • I am running on an up-to-date pypsa-eur environment. Update via conda env update -f envs/environment.yaml.

Describe the Bug

Running the sector coupled version for Sweden results in an error when clustering the gas network. This does not occur when running the same problem for Germany.

Error Message

ERROR:root:Uncaught exception
Traceback (most recent call last):
  File "/home/millinger/projects/pypsa-eur/.snakemake/scripts/tmpnmn5fb5t.cluster_gas_network.py", line 125, in <module>
    gas_network = build_clustered_gas_network(df, bus_regions)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/millinger/projects/pypsa-eur/.snakemake/scripts/tmpnmn5fb5t.cluster_gas_network.py", line 66, in build_clustered_gas_network
    df["length"] = df.apply(
    ~~^^^^^^^^^^
  File "/home/millinger/miniconda3/envs/pypsa-eur-new/lib/python3.11/site-packages/pandas/core/frame.py", line 4301, in __setitem__
    self._set_item_frame_value(key, value)
  File "/home/millinger/miniconda3/envs/pypsa-eur-new/lib/python3.11/site-packages/pandas/core/frame.py", line 4429, in _set_item_frame_value
    raise ValueError("Columns must be same length as key")
ValueError: Columns must be same length as key

I think this happens if the dataframe is empty (which it may be for Sweden). This was then probably fixed in #1183.