pymagicc icon indicating copy to clipboard operation
pymagicc copied to clipboard

Upgrade to pandas 2.0

Open phackstock opened this issue 1 year ago • 0 comments

As I was trying to update climate-assessment to use the latest scmdata to use pandas 2.0 (here: https://github.com/iiasa/climate-assessment/pull/46#issuecomment-1768050532) I got an error which looks to be related to pymagicc and pandas 2.0

Installing pymagicc and trying to run the tests gave me the following error:

(.venv) hackstock@nb-hackstock:~/Documents/code/pymagicc$ pytest
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 939, in _find_spec
AttributeError: 'AssertionRewritingHook' object has no attribute 'find_spec'
...
TypeError: required field "lineno" missing from alias

I was able to remedy that by upgrading pytest to the latest version. But then I got this error:

...
.venv/lib/python3.10/site-packages/pint_pandas/__init__.py:3: in <module>
    from .pint_array import PintArray, PintType
.venv/lib/python3.10/site-packages/pint_pandas/pint_array.py:198: in <module>
    np.complex128: pd.core.dtypes.dtypes.PandasDtype("complex128"),
E   AttributeError: module 'pandas.core.dtypes.dtypes' has no attribute 'PandasDtype'

which again seems to be related to pandas 2 and Pint-Pandas (version 0.4). Looks like pint-pandas version 0.5 fixes this. I tried updating to pint-pandas 0.5 but that poses a version conflict since pint-pandas 0.5 requires pint 0.22 and scmdata required pint 0.20 (https://github.com/openscm/scmdata/pull/271 and https://github.com/openscm/scmdata/issues/234).

Any help would be much appreciated.

Failing Test

Fails on import

phackstock avatar Oct 18 '23 12:10 phackstock