Open Jinyoung6177 opened 3 years ago
You could try porting the single lined fix I used to make my outdated 2017 case studies reproducible: ojdo/urbs@26462fb5c2efbed85081f9cbd9a079d415c58ce1
I have not taken the time to identify the source, but my guess is that openpyxl stopped to write the index names ('index', 'pro') into the result Excel files at some time in the past.
Unfortunately, I encountered the same problem and the single lined fix mentioned by @ojdo does not work either. @Jinyoung6177 Did you find another workaround to this? Thank you very much for your help.
https://github.com/tum-ens/urbs/pull/286#issue-753050907 Please see my comment/contribution here and the updated comp.py code below the comment, I corrected the code there.
The thing is the name 'level 1' or 'level 2' does not exist in the data. So I changed the index name. if you are still using old code, after solving the problem above you will encounter another problem with "sitcom". I also corrected this part in the corrected codes as well. Please see the codes in the link.
Hi everyone, I wanna run comp.py. I tried with $python, $python3, and $python3.6 to run the file but I get errors.
I have proper environment for running urbs already. Panda = 0.24.2, pyutilib =5.8.0 etc. Could you help me tackle this errors? Thanks a lot!
Below is with python3:
(base) yunjin-yeong-ui-MacBook-Air:~ YUNJINYOUNG$ conda activate urbs
(urbs) yunjin-yeong-ui-MacBook-Air:~ YUNJINYOUNG$ cd ~/urbs-master
(urbs) yunjin-yeong-ui-MacBook-Air:urbs-master YUNJINYOUNG$ python3 comp.py
File "/Users/YUNJINYOUNG/urbs-master/comp.py", line 15
def get_most_recent_entry(Users\YUNJINYOUNG\urbs-master\Input):
SyntaxError: unexpected character after line continuation character
(urbs) yunjin-yeong-ui-MacBook-Air:urbs-master YUNJINYOUNG$ python3 comp.py
Traceback (most recent call last):
File "/Users/YUNJINYOUNG/urbs-master/comp.py", line 259, in <module>
compare_scenarios(list(reversed(result_files)), comp_filename)
File "/Users/YUNJINYOUNG/urbs-master/comp.py", line 135, in compare_scenarios
esum.set_index(['level_0', 'level_1'], inplace=True)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/core/frame.py", line 4555, in set_index
raise KeyError(f"None of {missing} are in the columns")
KeyError: "None of ['level_0', 'level_1'] are in the columns"
And with python3.6:
(urbs) yunjin-yeong-ui-MacBook-Air:urbs-master YUNJINYOUNG$ python3.6 comp.py Traceback (most recent call last):
File "/Users/YUNJINYOUNG/opt/anaconda3/envs/urbs/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2657, in get_loc
return self._engine.get_loc(key)
File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'level_0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "comp.py", line 259, in <module>
compare_scenarios(list(reversed(result_files)), comp_filename)
File "comp.py", line 135, in compare_scenarios
esum.set_index(['level_0', 'level_1'], inplace=True)
File "/Users/YUNJINYOUNG/opt/anaconda3/envs/urbs/lib/python3.6/site-packages/pandas/core/frame.py", line 4178, in set_index
level = frame[col]._values
File "/Users/YUNJINYOUNG/opt/anaconda3/envs/urbs/lib/python3.6/site-packages/pandas/core/frame.py", line 2927, in __getitem__
indexer = self.columns.get_loc(key)
File "/Users/YUNJINYOUNG/opt/anaconda3/envs/urbs/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2659, in get_loc
return self._engine.get_loc(self._maybe_cast_indexer(key))
File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'level_0'
Lastly, with python:
(urbs) yunjin-yeong-ui-MacBook-Air:urbs-master YUNJINYOUNG$ python comp.py
Traceback (most recent call last):
File "/Users/YUNJINYOUNG/opt/anaconda3/envs/urbs/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2657, in get_loc
return self._engine.get_loc(key)
File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'level_0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "comp.py", line 259, in <module>
compare_scenarios(list(reversed(result_files)), comp_filename)
File "comp.py", line 135, in compare_scenarios
esum.set_index(['level_0', 'level_1'], inplace=True)
File "/Users/YUNJINYOUNG/opt/anaconda3/envs/urbs/lib/python3.6/site-packages/pandas/core/frame.py", line 4178, in set_index
level = frame[col]._values
File "/Users/YUNJINYOUNG/opt/anaconda3/envs/urbs/lib/python3.6/site-packages/pandas/core/frame.py", line 2927, in __getitem__
indexer = self.columns.get_loc(key)
File "/Users/YUNJINYOUNG/opt/anaconda3/envs/urbs/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2659, in get_loc
return self._engine.get_loc(self._maybe_cast_indexer(key))
File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'level_0'