UMEP-dev / SUEWS

Surface Urban Energy and Water Balance Scheme
https://suews.readthedocs.io/
Mozilla Public License 2.0
12 stars 6 forks source link

Supy pandas libraries error #254

Closed Empanag closed 3 months ago

Empanag commented 3 months ago

Describe the bug Hello i m struggling with this error at the moment

E:\SUEWSapp\Venv\lib\site-packages\supy\_post.py:14: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.
  df_var_list = df_var_list.applymap(lambda x: x.decode().strip())
2020-06-05 23:00:00                                                      ]   0%
2024-04-01 17:12:13,254 - SuPy - INFO - All cache cleared.
Traceback (most recent call last):
  File "E:\SUEWSapp\Venv\lib\site-packages\pandas\core\indexes\multi.py", line 1664, in _get_level_number
    level = self.names.index(level)
ValueError: 'var' is not in list

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "E:\SUEWSapp\final_setup\suews.py", line 639, in <module>
    suews_out=suews(filefolder)
  File "E:\SUEWSapp\final_setup\suews.py", line 445, in suews
    df_state_init = sp.init_supy(path_runcontrol)
  File "E:\SUEWSapp\Venv\lib\site-packages\supy\_supy_module.py", line 103, in init_supy
    df_state_init = load_InitialCond_grid_df(
  File "E:\SUEWSapp\Venv\lib\site-packages\supy\_load.py", line 1629, in load_InitialCond_grid_df
    df_init = trim_df_state(df_init)
  File "E:\SUEWSapp\Venv\lib\site-packages\supy\_load.py", line 1193, in trim_df_state
    ind_incl = df_state.columns.get_level_values("var").isin(set_var_use)
  File "E:\SUEWSapp\Venv\lib\site-packages\pandas\core\indexes\multi.py", line 1832, in get_level_values
    level = self._get_level_number(level)
  File "E:\SUEWSapp\Venv\lib\site-packages\pandas\core\indexes\multi.py", line 1667, in _get_level_number
    raise KeyError(f"Level {level} not found") from err
KeyError: 'Level var not found'

To Reproduce final_setup.zip

final_setupCO2.zip

Version and platform (please complete the following information):

Package Version


affine 2.4.0 asteval 0.9.32 atmosp 0.2.9 attrs 23.2.0 cdsapi 0.6.1 certifi 2024.2.2 charset-normalizer 3.3.2 click 8.1.7 click-plugins 1.1.1 cligj 0.7.2 cloudpickle 3.0.0 colorama 0.4.6 contourpy 1.2.0 cycler 0.12.1 dask 2024.3.1 dill 0.3.8 f90nml 1.4.4 Fiona 1.8.21 fonttools 4.50.0 fsspec 2024.3.1 future 1.0.0 GDAL 3.4.3 h5py 3.10.0 idna 3.6 importlib_metadata 7.1.0 kiwisolver 1.4.5 linecache2 1.0.0 lmfit 1.2.2 locket 1.0.0 matplotlib 3.8.3 multiprocess 0.70.16 munch 4.0.0 nose 1.3.7 numdifftools 0.9.41 numexpr 2.9.0 numpy 1.26.4 packaging 24.0 pandas 2.2.1 partd 1.4.1 pillow 10.3.0 Pint 0.23 pip 22.2.2 Platypus-Opt 1.0.4 progressbar 2.5 pvlib 0.10.4 pyparsing 3.1.2 pyproj 3.3.1 python-dateutil 2.9.0.post0 pytz 2024.1 PyYAML 6.0.1 rasterio 1.2.10 requests 2.31.0 scipy 1.12.0 seaborn 0.13.2 setuptools 63.2.0 Shapely 1.8.2 six 1.16.0 snuggs 1.4.7 supy 2022.4.7 supy-driver 2021a5 toolz 0.12.1 tqdm 4.66.2 traceback2 1.4.0 typing_extensions 4.10.0 tzdata 2024.1 uncertainties 3.1.7 unittest2 1.1.0 urllib3 2.2.1 xarray 2024.3.0 zipp 3.18.1

Additional context Add any other context about the problem here.

Empanag commented 3 months ago

Describe the bug Hello i m struggling with this error at the moment

E:\SUEWSapp\Venv\lib\site-packages\supy\_post.py:14: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.
  df_var_list = df_var_list.applymap(lambda x: x.decode().strip())
2020-06-05 23:00:00                                                      ]   0%
2024-04-01 17:12:13,254 - SuPy - INFO - All cache cleared.
Traceback (most recent call last):
  File "E:\SUEWSapp\Venv\lib\site-packages\pandas\core\indexes\multi.py", line 1664, in _get_level_number
    level = self.names.index(level)
ValueError: 'var' is not in list

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "E:\SUEWSapp\final_setup\suews.py", line 639, in <module>
    suews_out=suews(filefolder)
  File "E:\SUEWSapp\final_setup\suews.py", line 445, in suews
    df_state_init = sp.init_supy(path_runcontrol)
  File "E:\SUEWSapp\Venv\lib\site-packages\supy\_supy_module.py", line 103, in init_supy
    df_state_init = load_InitialCond_grid_df(
  File "E:\SUEWSapp\Venv\lib\site-packages\supy\_load.py", line 1629, in load_InitialCond_grid_df
    df_init = trim_df_state(df_init)
  File "E:\SUEWSapp\Venv\lib\site-packages\supy\_load.py", line 1193, in trim_df_state
    ind_incl = df_state.columns.get_level_values("var").isin(set_var_use)
  File "E:\SUEWSapp\Venv\lib\site-packages\pandas\core\indexes\multi.py", line 1832, in get_level_values
    level = self._get_level_number(level)
  File "E:\SUEWSapp\Venv\lib\site-packages\pandas\core\indexes\multi.py", line 1667, in _get_level_number
    raise KeyError(f"Level {level} not found") from err
KeyError: 'Level var not found'

To Reproduce final_setup.zip

final_setupCO2.zip

Version and platform (please complete the following information):

  • SUEWS version: 2022.4.7
  • OS: windows

Package Version

affine 2.4.0 asteval 0.9.32 atmosp 0.2.9 attrs 23.2.0 cdsapi 0.6.1 certifi 2024.2.2 charset-normalizer 3.3.2 click 8.1.7 click-plugins 1.1.1 cligj 0.7.2 cloudpickle 3.0.0 colorama 0.4.6 contourpy 1.2.0 cycler 0.12.1 dask 2024.3.1 dill 0.3.8 f90nml 1.4.4 Fiona 1.8.21 fonttools 4.50.0 fsspec 2024.3.1 future 1.0.0 GDAL 3.4.3 h5py 3.10.0 idna 3.6 importlib_metadata 7.1.0 kiwisolver 1.4.5 linecache2 1.0.0 lmfit 1.2.2 locket 1.0.0 matplotlib 3.8.3 multiprocess 0.70.16 munch 4.0.0 nose 1.3.7 numdifftools 0.9.41 numexpr 2.9.0 numpy 1.26.4 packaging 24.0 pandas 2.2.1 partd 1.4.1 pillow 10.3.0 Pint 0.23 pip 22.2.2 Platypus-Opt 1.0.4 progressbar 2.5 pvlib 0.10.4 pyparsing 3.1.2 pyproj 3.3.1 python-dateutil 2.9.0.post0 pytz 2024.1 PyYAML 6.0.1 rasterio 1.2.10 requests 2.31.0 scipy 1.12.0 seaborn 0.13.2 setuptools 63.2.0 Shapely 1.8.2 six 1.16.0 snuggs 1.4.7 supy 2022.4.7 supy-driver 2021a5 toolz 0.12.1 tqdm 4.66.2 traceback2 1.4.0 typing_extensions 4.10.0 tzdata 2024.1 uncertainties 3.1.7 unittest2 1.1.0 urllib3 2.2.1 xarray 2024.3.0 zipp 3.18.1

Additional context Add any other context about the problem here.

after some testing I used pandas 1.5.0 and works now.