PyPSA / pypsa-eur

PyPSA-Eur: A Sector-Coupled Open Optimisation Model of the European Energy System
https://pypsa-eur.readthedocs.io/
309 stars 208 forks source link

prepare_hotmaps_database tries to use non-existing column "index_right" #1124

Open fhg-isi opened 4 days ago

fhg-isi commented 4 days ago

Describe the Bug

When trying to run the script build_industrial_distribution_key.py I get the error below.

The cause seems to be that the column "index_right" does not exist in gdf.

    gdf.rename(columns={"index_right": "bus"}, inplace=True)
    gdf["country"] = gdf.bus.str[:2]

Maybe the format of the hotmaps file changed?

=> Replace the line with

gdf["country"] = gdf["Country"] ?

Or just use existing column "Country"?

Error Message

(pypsa-eur) projekt-resilient03@ubuntu-22-04-lts-temp:~/pypsa-eur$ python scripts/build_industrial_distribution_key.py
ERROR:root:Uncaught exception
Traceback (most recent call last):
  File "/home/projekt-resilient03/pypsa-eur/scripts/build_industrial_distribution_key.py", line 189, in <module>
    hotmaps = prepare_hotmaps_database(regions)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/projekt-resilient03/pypsa-eur/scripts/build_industrial_distribution_key.py", line 120, in prepare_hotmaps_database
    gdf["country"] = gdf.bus.str[:2]
                     ^^^^^^^
  File "/home/projekt-resilient03/conda/envs/pypsa-eur/lib/python3.11/site-packages/pandas/core/generic.py", line 6299, in __getattr__
    return object.__getattribute__(self, name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'GeoDataFrame' object has no attribute 'bus'

Related:

https://github.com/PyPSA/pypsa-eur/issues/1118

https://github.com/PyPSA/pypsa-eur/issues/1123

fhg-isi commented 4 days ago

Similar issue in build_gas_input_locations.py:

gas_input_nodes.rename(columns={"index_right": "bus"}, inplace=True)