Notebook Mode

Contents

Notebook Mode#

Activate ITables in a Jupyter environment for all your tables with init_notebook_mode:

import itables

itables.init_notebook_mode()

You can go back to the standard HTML representation of Pandas DataFrames with init_notebook_mode(all_interactive=False).

df = itables.sample_dfs.get_countries()
df
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
AEMiddle East & North AfricaUnited Arab EmiratesAbu Dhabi54.37050024.476400
ARLatin America & Caribbean ArgentinaBuenos Aires-58.417300-34.611800
AMEurope & Central AsiaArmeniaYerevan44.50900040.159600
ASEast Asia & PacificAmerican SamoaPago Pago-170.691000-14.284600
AGLatin America & Caribbean Antigua and BarbudaSaint John's-61.84560017.117500
(198 more rows not shown)

Note that the init_notebook_mode function also activates ITables’ offline mode, unless you call it with a connected=False argument.

Offline mode#

By default init_notebook_mode configures ITables to work offline (except in Colab). No internet connection is required as the JavaScript code is embedded into the notebook itself when you execute init_notebook_mode.

In some contexts (Jupyter Book, Google Colab, etc…) you might prefer to load the libraries dynamically from the internet. To do so, add the argument connected=True when you execute init_notebook_mode. This will also make your notebook lighter by about 900kB. Note that, in Google Colab, connected=True is the only working option.

Show#

If you prefer to render only certain tables using itables, or want to set additional options, use show:

itables.show(df, caption="A DataFrame rendered with ITables")
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
AEMiddle East & North AfricaUnited Arab EmiratesAbu Dhabi54.37050024.476400
ARLatin America & Caribbean ArgentinaBuenos Aires-58.417300-34.611800
AMEurope & Central AsiaArmeniaYerevan44.50900040.159600
ASEast Asia & PacificAmerican SamoaPago Pago-170.691000-14.284600
AGLatin America & Caribbean Antigua and BarbudaSaint John's-61.84560017.117500
A DataFrame rendered with ITables
(198 more rows not shown)