From 04ccad99340caf823bb5b0cf9653d30ccba0fcdf Mon Sep 17 00:00:00 2001 From: Michael Pilosov <40366263+mathematicalmichael@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:24:37 -0700 Subject: [PATCH] address pandas deprecation warning ``` .../lib/python3.10/site-packages/lifelines/fitters/cox_time_varying_fitter.py:819: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas. Value '0.6058777002252564' has dtype incompatible with int64, please explicitly cast to a compatible dtype first. ``` this warning goes away with this change. `pandas==2.1.4` --- lifelines/fitters/cox_time_varying_fitter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lifelines/fitters/cox_time_varying_fitter.py b/lifelines/fitters/cox_time_varying_fitter.py index cb48f7925..d58cb4112 100644 --- a/lifelines/fitters/cox_time_varying_fitter.py +++ b/lifelines/fitters/cox_time_varying_fitter.py @@ -801,7 +801,7 @@ def _compute_cumulative_baseline_hazard(self, tv_data, events, start, stop, weig hazards = self.predict_partial_hazard(tv_data).values unique_death_times = np.unique(stop[events.values]) - baseline_hazard_ = pd.DataFrame(np.zeros_like(unique_death_times), index=unique_death_times, columns=["baseline hazard"]) + baseline_hazard_ = pd.DataFrame(np.zeros_like(unique_death_times).astype(float), index=unique_death_times, columns=["baseline hazard"]) for t in unique_death_times: ix = (start.values < t) & (t <= stop.values)