Skip to main content

ITables in Quarto

Interactive Tables in HTML reports

How to use ITables in Quarto

NoteActivate ITables (same as in Jupyter, VS Code, PyCharm, Google Colab…)
import itables

itables.init_notebook_mode(all_interactive=True)
… and all DataFrames become interactive!
itables.sample_dfs.get_countries()
ⓘ region country capital longitude latitude
code
AWLatin America & Caribbean ArubaOranjestad-70.01670012.516700
AFSouth AsiaAfghanistanKabul69.17610034.522800
AOSub-Saharan Africa AngolaLuanda13.242000-8.811550
ALEurope & Central AsiaAlbaniaTirane19.81720041.331700
ADEurope & Central AsiaAndorraAndorra la Vella1.52180042.507500
(203 more rows not shown)

How to make my table fit in the report?

TipHow to make your table smaller
  • display only a few rows with lengthMenu,
  • adjust the style or font with a custom css
NoteThis document uses
from IPython.display import display, HTML

# show 5 rows per 'page'
itables.options.lengthMenu = [5]

# don't show the length control
itables.options.layout["topStart"] = None

# use a smaller font (default is medium)
# see https://developer.mozilla.org/en-US/docs/Web/CSS/font-size
display(HTML("<style>.dt-container { font-size: small; }</style>"))

Advanced Parameters

TipParameters

ITables’ advanced parameters:

  • Can be set globally on itables.options, or
  • Passed as arguments to the show function.
  • Table-specific arguments like caption are only available in show.
WarningGlobal Options and Quarto’s cache

Quarto uses a cache that may prevent your changes on itables.options to become effective when you run quarto render.

In that case, use --cache-refresh or even --execute-daemon-restart.

About ITables

NoteGitHub Star

ITables is developed by Marc Wouts on GitHub, under a MIT license. ITables is a wrapper for datatables.net which is developed by Allan Jardine (sponsor him!), also under a MIT license.

TipUnder the hood

ITables renders Pandas or Polars DataFrames as interactive HTML tables using the JavaScript DataTables library.

TipDocumentation

Learn More about ITables in the documentation.