Utils
pydts.utils.get_expanded_df(df, event_type_col='J', duration_col='X', pid_col='pid')
ยค
Expands a discrete-time survival dataset into a long-format dataframe suitable for modeling. This function receives a dataframe where each row corresponds to a subject with observed event type and duration. It returns an expanded dataframe where each subject is represented by multiple rows, one for each time point up to their observed time. Right censoring is allowed and should be indicated by event type 0.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
Original input dataframe containing one row per subject. |
required |
event_type_col
|
str
|
Name of the column indicating event type. Censoring is marked by 0. |
'J'
|
duration_col
|
str
|
Name of the column indicating event or censoring time. |
'X'
|
pid_col
|
str
|
Name of the column indicating subject/patient ID. |
'pid'
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Expanded dataframe in long format, with one row per subject-time pair. |