Report.add_great_table

add_great_table

add_great_table(table: GT, *, title: str = '', caption: str | None = None, notes: str | None = None, id: str | None = None) -> ReportItem

Add a Great Tables table to the report.

Parameters:
  • table (GT) –

    great_tables GT object

  • title (str, default: '' ) –

    optional visible heading

  • caption (str | None, default: None ) –

    optional caption

  • notes (str | None, default: None ) –

    optional explanatory notes

  • id (str | None, default: None ) –

    optional stable component id

Notes

The table is rendered using great_tables html export The native table row limit does not apply

Installation

Great Tables is optional; install it separately:

pip install great-tables

Example

import polars as pl
from great_tables import GT

frequency = pl.DataFrame({'enctype': ['ED', 'Inpatient'], 'count': [1200, 350]})
table = (
    GT(frequency)
    .tab_header(title='Encounter types')
    .fmt_number(columns='count', decimals=0)
)
report.add_great_table(table)

Optional report-level metadata can also be supplied:

report.add_great_table(
    table,
    title='Encounter counts',
    caption='Table 1. Encounter types.',
    notes='Counts represent encounters, not unique patients.',
    id='encounters',
)

Notes

Great Tables renders the table using as_raw_html(); polarstory inserts the resulting HTML fragment. Configure formatting through Great Tables. The native Report.max_table_rows limit does not apply to external tables.

Static tables are recommended for offline and printable reports. Interactive tables and external resources may introduce dependencies. Use trusted content and check small cells and identifiers before sharing.

Great Tables components cannot be regenerated from JSON report recipes. Retain the Python script that creates the table.

See the Great Tables documentation for formatting options, or Report.add_html() for arbitrary HTML fragments.

← Reports API