summaries.tidy()

Return a standardised term-level DataFrame for a fitted model.

Usage

Source

summaries.tidy(
    model,
    **kwargs,
)

Produces one row per model term (coefficient, parameter, or stratum) with columns for the estimate, standard error, and confidence limits. This is the Python equivalent of R’s broom::tidy().

Parameters

model: object

A fitted Greenwood estimator (e.g., KaplanMeier, CoxPH, AFT, Parametric).

**kwargs: Any
Forwarded to the registered adapter. Common options include format= to choose the output backend ("pandas", "polars", or "pyarrow").

Returns

DataFrame
A tidy, term-level summary of the fitted model.

Examples

Tidy a fitted Cox model into a Polars DataFrame:

import greenwood as gw

# Load data, build a right-censored response, and fit a Cox model
lung = gw.load_dataset("lung", backend="polars")
y = gw.Surv.right(lung["time"], event=(lung["status"] == 2))
cox = gw.CoxPH().fit(y, covariates=lung[["age", "sex"]])

# Tidy the coefficients into a Polars DataFrame
gw.tidy(cox, format="polars")
shape: (2, 7)
termestimatestd_errorstatisticp_valueconf_lowconf_high
strf64f64f64f64f64f64
"age"0.0170450.0092231.8480780.064591-0.0010320.035123
"sex"-0.5132190.167458-3.064760.002178-0.84143-0.185007