SummaryTable#
- class ns_sdn.summary.SummaryTable(title, metadata=(), columns=(), rows=(), notes=())#
A rendered-on-demand estimation summary.
Holds the structure of a summary rather than a formatted string: a title, label/value metadata pairs rendered two per line, one table, and closing notes. Renders as fixed-width text (
to_text(), which is alsostrandrepr), as HTML in a notebook (_repr_html_), or as a dataframe (to_pandas()), and imports nothing optional until a frame is asked for. Every value is already a string: the producer decides the number formatting, the table decides the layout.The text layout is the econometric convention: a centred title, a rule, the metadata in two columns of
label: valuepairs, a rule, the table with its first column left-aligned and the rest right-aligned, a rule, and the notes word-wrapped to the table width (at least 80 characters).- Variables:
title – Headline.
metadata – Label/value pairs describing the fit, laid out two per line in the order given.
columns – Column headers; the first names the row key and may be empty.
rows – Table rows; the first entry of each is the row key and the rest align with
columns[1:].notes – Closing lines stating what the numbers assume.
Example
>>> from ns_sdn.summary import SummaryTable >>> table = SummaryTable( ... title="Demo", ... metadata=(("Observations", "99"), ("Parameters", "7")), ... columns=("", "mean", "share"), ... rows=(("component 1", "0.50", "0.800"), ("component 2", "0.10", "0.200")), ... notes=("Shares sum to one.",), ... ) >>> print(table) Demo ================================================================================ Observations: 99 Parameters: 7 -------------------------------------------------------------------------------- mean share component 1 0.50 0.800 component 2 0.10 0.200 ================================================================================ Shares sum to one. >>> table.to_pandas().loc["component 2", "share"] '0.200'
Attributes#
Methods#
The table as a |
|
|
Render the summary as fixed-width text. |