Breakthrough-Energy / PreREISE

Generate input data for scenario framework
https://breakthrough-energy.github.io/docs/
MIT License
20 stars 28 forks source link

Update dependencies #332

Closed rouille closed 1 year ago

rouille commented 1 year ago

Pull Request doc

Purpose

Bump xlrd to 2.0.1 to be able to read excel file with pandas. Also, the lockfile has been regenerated

What the code is doing

N/A

Testing

Existing unit tests

Where to look

Before:

>>> import pandas as pd
>>> census = pd.read_excel("https://www2.census.gov/geo/docs/reference/ua/ua_st_list_all.xls")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/brdo/.local/share/virtualenvs/PreREISE-Yr21Ys7H/lib/python3.10/site-packages/pandas/util/_decorators.py", line 211, in wrapper
    return func(*args, **kwargs)
  File "/Users/brdo/.local/share/virtualenvs/PreREISE-Yr21Ys7H/lib/python3.10/site-packages/pandas/util/_decorators.py", line 331, in wrapper
    return func(*args, **kwargs)
  File "/Users/brdo/.local/share/virtualenvs/PreREISE-Yr21Ys7H/lib/python3.10/site-packages/pandas/io/excel/_base.py", line 482, in read_excel
    io = ExcelFile(io, storage_options=storage_options, engine=engine)
  File "/Users/brdo/.local/share/virtualenvs/PreREISE-Yr21Ys7H/lib/python3.10/site-packages/pandas/io/excel/_base.py", line 1695, in __init__
    self._reader = self._engines[engine](self._io, storage_options=storage_options)
  File "/Users/brdo/.local/share/virtualenvs/PreREISE-Yr21Ys7H/lib/python3.10/site-packages/pandas/io/excel/_xlrd.py", line 34, in __init__
    import_optional_dependency("xlrd", extra=err_msg)
  File "/Users/brdo/.local/share/virtualenvs/PreREISE-Yr21Ys7H/lib/python3.10/site-packages/pandas/compat/_optional.py", line 171, in import_optional_dependency
    raise ImportError(msg)
ImportError: Pandas requires version '2.0.1' or newer of 'xlrd' (version '1.2.0' currently installed).

After:

>>> import pandas as pd
>>> census = pd.read_excel("https://www2.census.gov/geo/docs/reference/ua/ua_st_list_all.xls")
>>> census
     Alabama                  Unnamed: 1           .1     .2 Unnamed: 5        .3            .4 Unnamed: 8     Unnamed: 9 Unnamed: 10 Unnamed: 11
0        NaN                         NaN    NaN   NaN    NaN        NaN       NaN           NaN        NaN            NaN         NaN         NaN
1       UACE                        NAME  STATE  PART    POP         HU  AREALAND  AREALANDSQMI  AREAWATER  AREAWATERSQMI      POPDEN       LSADC
2      01036             Albertville, AL     01        36815      14980  92837874         35.84    5174684              2      1027.1          76
3      01252          Alexander City, AL     01         9400       4326  25158641          9.71      65446           0.03       967.7          76
4      02359               Andalusia, AL     01         6655       3187  14927092          5.76      32462           0.01      1154.7          76
...      ...                         ...    ...   ...    ...        ...       ...           ...        ...            ...         ...         ...
4096     NaN                         NaN    NaN   NaN    NaN        NaN       NaN           NaN        NaN            NaN         NaN         NaN
4097    UACE                        NAME  STATE  PART    POP         HU  AREALAND  AREALANDSQMI  AREAWATER  AREAWATERSQMI      POPDEN       LSADC
4098   15697  Charlotte Amalie--Tutu, VI     78        50916      26720  62937296          24.3     354135           0.14      2095.3          76
4099   16750           Christiansted, VI     78        46601      22419  91219580         35.22      97609           0.04      1323.1          76
4100   21475                Cruz Bay, VI     78         3090       2464   7988028          3.08      82572           0.03      1001.9          76

[4101 rows x 12 columns]

Usage Example/Visuals

N/A

Time estimate

2min