import pandas as pd
import great_docs as gd
df = pd.DataFrame({"name": ["Alice", "Bob", "Carol"], "score": [92, 87, 95]})enable_tbl_preview()
Register tbl_preview() as the default DataFrame display formatter.
Usage
enable_tbl_preview(**kwargs)After calling this, any Polars or Pandas DataFrame that is the last expression in a cell (or passed to display()) will be rendered as a tbl_preview() table instead of the libraryβs default HTML.
Parameters
**kwargs: Any-
Keyword arguments forwarded to tbl_preview() (e.g.,
n_head=10,show_all=True,show_dimensions=False).
Returns
None-
The formatter is registered as a side effect. IPython suppresses
Noneoutput, so nothing is printed in the cell.
Examples
Before enabling, the DataFrame renders with default Pandas HTML:
df| name | score | |
|---|---|---|
| 0 | Alice | 92 |
| 1 | Bob | 87 |
| 2 | Carol | 95 |
After enabling, the same DataFrame renders as a tbl_preview() table:
gd.enable_tbl_preview(n_head=3)
dfPandasRows3Columns2 | ||
name str |
score i64 |
|
|---|---|---|
| 0 | Alice | 92 |
| 1 | Bob | 87 |
| 2 | Carol | 95 |
From this point on, all DataFrames (Pandas, Polars, or otherwise) will render using tbl_preview() until disable_tbl_preview() is called.
See Also
- disable_tbl_preview(): Remove the formatter and restore default display.
- tbl_preview(): Generate a preview table for a single DataFrame.