CaMa survival: no member is followed past today

This commit is contained in:
Roberto Treviño Cervantes
2026-11-22 18:04:57 -06:00
parent d91ac7c14b
commit 5a10be44d0
+1 -1
View File
@@ -103,7 +103,7 @@ def outcome_table(cohort: pd.DataFrame, cutoff, cap_months: int) -> pd.DataFrame
frame = _dated(cohort)
index = frame.groupby("pac_id")["fecha_indice"].first()
death = frame[frame["tipo"] == "defuncion"].groupby("pac_id")["fecha"].min().reindex(index.index)
cutoff = pd.Timestamp(cutoff)
cutoff = min(pd.Timestamp(cutoff), pd.Timestamp.today().normalize()) # nobody is followed past today
died = (death.notna() & (death <= cutoff)).to_numpy()
end = death.where(died, cutoff)
months = np.floor((end - index).dt.days.to_numpy() / DAYS_PER_MONTH).astype(int).clip(min=0)