alexanderkell / elecsim

Long term electricity market agent based model simulation used to observe the effect of policy on investment decisions
https://elecsim.readthedocs.io
MIT License
46 stars 11 forks source link

Compatibility issues with panda 2.0 #87

Open LotharBrixius opened 1 year ago

LotharBrixius commented 1 year ago

Hey,

First of all thanks for all the effort! However I found a piece of code that needs to be updated, see the following StackOverflow entry: https://stackoverflow.com/questions/75956209/error-dataframe-object-has-no-attribute-append

File ~\anaconda3\lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec exec(code, globals, locals)

File c:\users\lothar\documents\github\elecsim\tst.py:1 from elecsim.model.world import World

File ~\Documents\GitHub\elecsim\elecsim__init__.py:1 from elecsim.model.world import World

File ~\Documents\GitHub\elecsim\elecsim\model\world.py:15 from elecsim.plants.fuel.capacity_factor.capacity_factor_calculations import (

File ~\Documents\GitHub\elecsim\elecsim\plants\fuel\capacity_factor\capacity_factor_calculations.py:9 import elecsim.scenario.scenario_data

File ~\Documents\GitHub\elecsim\elecsim\scenario\scenario_data.py:143 carbon_price_all_years = concatenate_carbon_price()

File ~\Documents\GitHub\elecsim\elecsim\scenario\scenario_data.py:138 in concatenate_carbon_price carbon_cost = historical_carbon_price.append(carbon_price_scenario_df, sort=True)

File ~\anaconda3\lib\site-packages\pandas\core\generic.py:5989 in getattr return object.getattribute(self, name)

AttributeError: 'DataFrame' object has no attribute 'append'

alexanderkell commented 1 year ago

Hi @LotharBrixius,

Thanks for your message. Unfortunately, I no longer have time to maintain this project. I recommend trying to downgrade your pandas version to a version before 2.0. Otherwise you are more than welcome to try and fix it and open a PR!

Best wishes, Alex

LotharBrixius commented 1 year ago

So this should be the appropriate fix: in scenario_data.py replace the following line (138) from the definition of concatenate_carbon_price():

OUTDATED Panda: carbon_cost = historical_carbon_price.append(carbon_price_scenario_df, sort=True)

Panda 2.1.: carbon_cost = pd.concat([historical_carbon_price,carbon_price_scenario_df], ignore_index=True)

I have not done any thorough testing yet however.