vvcb / comorbidipy

Python package to calculate comorbidity scores including Charlson Comorbidity Score and Elixhauser Score and their weighted variants.
MIT License
10 stars 5 forks source link

Error with Pandas version 2 #3

Open davideyre opened 1 year ago

davideyre commented 1 year ago

Description

Comorbidipy works fine with pandas 1.4.0, but when trying to run with a more recent version I get this error, e.g. version 1.5.0 or version 2.0.1

Traceback (most recent call last):
  File "main.py", line 7, in <module>
    from comorbidipy import comorbidity
  File "venv/lib/python3.9/site-packages/comorbidipy/__init__.py", line 7, in <module>
    from .calculator import comorbidity, hfrs, disability
  File "venv/lib/python3.9/site-packages/comorbidipy/calculator.py", line 5, in <module>
    from pandas.core.common import SettingWithCopyWarning
ImportError: cannot import name 'SettingWithCopyWarning' from 'pandas.core.common' (venv/lib/python3.9/site-packages/pandas/core/common.py)

The issue seems to be that the import is now in pandas.errors, this doesn't work -

from pandas.core.common import SettingWithCopyWarning

But this does

 from pandas.errors import SettingWithCopyWarning
Padmapalita commented 1 year ago

Upvoting this issue.

rbngz commented 11 months ago

It seems to be fixed with the recent commit but has not yet been published to PyPi. Simply install from Github using the commit hash:

pip install git+https://github.com/vvcb/comorbidipy.git@c676a8067ce343704d75bcf8180f9baa1ac47664

Make sure to uninstall any previous version first using

pip uninstall comorbidipy
smgpulse007 commented 8 months ago

Goto calculator.py ~AppData\Local\Programs\Python\Python311\Lib\site-packages\comorbidipy

Change from pandas.core.common import SettingWithCopyWarning

TO from pandas.errors import SettingWithCopyWarning

@vvcb This fixes the issue and the import works as described in the docs

MattStammers commented 6 months ago

It seems to be fixed with the recent commit but has not yet been published to PyPi. Simply install from Github using the commit hash:

pip install git+https://github.com/vvcb/comorbidipy.git@c676a8067ce343704d75bcf8180f9baa1ac47664

Make sure to uninstall any previous version first using

pip uninstall comorbidipy

@rbngz is right. @vvcb you need to patch the current pypi version.