Return a standardised term-level DataFrame for a fitted model.
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)| term | estimate | std_error | statistic | p_value | conf_low | conf_high |
|---|
| str | f64 | f64 | f64 | f64 | f64 | f64 |
| "age" | 0.017045 | 0.009223 | 1.848078 | 0.064591 | -0.001032 | 0.035123 |
| "sex" | -0.513219 | 0.167458 | -3.06476 | 0.002178 | -0.84143 | -0.185007 |