CamDavidsonPilon / lifelines

Survival analysis in Python
lifelines.readthedocs.org
MIT License
2.35k stars 557 forks source link

Compatibility issue with pandas 2.0.0 #1512

Closed DrShushen closed 1 year ago

DrShushen commented 1 year ago

Hi,

There appears to be a problem with pandas 2.0.0.

Some system info, hopefully useful: OS: Ubuntu 22.04 Versions:

lifelines 0.27.4
pandas 2.0.0
numpy 1.23.5

Replicating the error:

# reproduce.py

from lifelines.datasets import load_rossi
from lifelines import CoxPHFitter

rossi = load_rossi()
cph = CoxPHFitter().fit(rossi, 'week', 'arrest')

axes = cph.check_assumptions(rossi, show_plots=True)

This throws the error:

Traceback (most recent call last):
  File "./reproduce.py", line 15, in <module>
    fitter.fit(rossi, "week", "arrest")
  File "/<...>/lifelines/utils/__init__.py", line 56, in f
    return function(model, *args, **kwargs)
  File "/<...>/lifelines/fitters/coxph_fitter.py", line 290, in fit
    self._model = self._fit_model(
  File "/<...>/lifelines/fitters/coxph_fitter.py", line 610, in _fit_model
    return self._fit_model_breslow(*args, **kwargs)
  File "/<...>/lifelines/fitters/coxph_fitter.py", line 623, in _fit_model_breslow
    model.fit(*args, **kwargs)
  File "/<...>/lifelines/utils/__init__.py", line 56, in f
    return function(model, *args, **kwargs)
  File "/<...>/lifelines/fitters/coxph_fitter.py", line 1242, in fit
    self._central_values = self._compute_central_values_of_raw_training_data(df, self.strata)
  File "/<...>/lifelines/fitters/__init__.py", line 1286, in _compute_central_values_of_raw_training_data
    described = df.describe(include="all", **describe_kwarg)
TypeError: describe() got an unexpected keyword argument 'datetime_is_numeric'

Seems to be the same issue as this, fixed as here.

CamDavidsonPilon commented 1 year ago

Thanks @DrShushen for the report! I suspect this isn't the only issue. I'll update soon, as I'd like to test out new Pandas features too

DrShushen commented 1 year ago

@CamDavidsonPilon Great, no problem!

DrShushen commented 1 year ago

I see this has been reopened - just wondering what the status of pandas 2 compatibility is as of lifelines v0.27.6?

CamDavidsonPilon commented 1 year ago

It was automatically closed from a PR, but at the time I wasn't confident this was solved. However, I believe it can be closed now. I locally tested pandas 2.0, and fixed any issues that came up. Should be good to go in 0.27.6.