Skip to content

survival_table_from_events intervals outside of maximum causes error #1587

@swit22

Description

@swit22

When using collapse = True and intervals in lifelines.utils.survival_table_from_events, a 'Cannot convert non-finite values (NA or inf) to integer' ValueError is thrown when any of the intervals exceed the maximum time of the observations. This makes it difficult to use uniform intervals for multiple populations. I'm also seeing this error happen occasionally even when the intervals don't exceed the bounds of the observations.
I'm aiming to use the survival_table_from_events to get a table with one row per year up to a set year, where values are zero beyond the maximum year of the population.
Using lifelines version 0.27.7
from lifelines.datasets import load_waltons
from lifelines.utils import survival_table_from_events
import numpy as np
waltons = load_waltons()
survival_table_from_events(waltons['T'], waltons['E'], collapse = True, intervals = np.arange(10,100).tolist())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions