Skip to content

Commit

Permalink
address pandas deprecation warning
Browse files Browse the repository at this point in the history
```
.../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`
  • Loading branch information
mathematicalmichael authored Feb 14, 2024
1 parent 2bd0627 commit 04ccad9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lifelines/fitters/cox_time_varying_fitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 04ccad9

Please sign in to comment.