Skip to content
Framework

Notebooks and scripts

show_table()

Show a table in a Quarto page or Jupyter notebook, as knitr::kable() does in R.

The result is a Markdown pipe table. Quarto makes it a real table in HTML, PDF, and Word, styled like the page, so it stays small in a page with embed-resources. Jupyter, VS Code, and Positron show it as a table, and print() shows its Markdown. Numeric columns are right-aligned and others left-aligned. Every row is shown, so summarize first.

Usage

show_table(
    data: Any,
    caption: str | None = None,
    digits: int | None = None,
    big_mark: str = '',
    na: str = '',
    index: bool = False,
) -> TableDisplay

Arguments

Name Type Default Description
data required Any

A pandas or polars DataFrame or Series, or a numpy array.

caption str | None None

A caption below the table. In Quarto, #| tbl-cap on the cell does the same and adds a cross-reference label with #| label: tbl-...; use one or the other.

digits int | None None

Decimal places for floating-point numbers, kept even when they are zero (2 shows 1.50). Default: whole numbers without decimals and other numbers as Python prints them.

big_mark str ''

The thousands separator for numbers, such as ",". Default: none.

na str ''

What a missing value shows. Default: an empty cell.

index bool False

Show the DataFrame's index as the first column.

Value

A TableDisplay, which a notebook shows as the table when it is the last line of a cell. Call IPython.display.display() on it to show it from elsewhere.

Raises

  • FrameworkError: When data is not table-like, or digits is negative.

Search guides and reference for R, Python, Stata, the CLI, and Framework Cloud.