ITables Logo

CI codecov.io MIT License Pypi Conda Version pyversions Code style: black Jupyter Widget Dash Component Streamlit App

This packages changes how Pandas and Polars DataFrames are rendered in Jupyter Notebooks. With itables you can display your tables as interactive DataTables that you can sort, paginate, scroll or filter.

ITables is just about how tables are displayed. You can turn it on and off in just two lines, with no other impact on your data workflow.

The itables package depends only on numpy, pandas and IPython which you must already have if you work with Pandas in Jupyter (add polars, pyarrow if you work with Polars DataFrames).

Quick Start#

Installation#

Install the itables package with either

pip install itables

or

conda install itables -c conda-forge

Activate ITables in a Notebook#

Activate the interactive mode in notebook-like environment with init_notebook_mode:

import itables

itables.init_notebook_mode()

After this, any Pandas or Polars DataFrame, or Series, is displayed as an interactive DataTables, which lets you explore, filter or sort your data.

df = itables.sample_dfs.get_countries(html=False)
df
region country capital longitude latitude
code
Loading ITables v2.3.0 from the init_notebook_mode cell... (need help?)

Tip

The arguments to init_notebook_mode are:

  • all_interactive, which defaults to True since v2.3.0

  • connected, which defaults to False (except in Colab)

If you prefer to render only certain tables using itables, or want to pass advanced parameters along with the DataFrame, use show:

itables.show(df, lengthMenu=[2, 5, 10, 25, 50, 100, 250])
region country capital longitude latitude
code
Loading ITables v2.3.0 from the init_notebook_mode cell... (need help?)

Offline mode versus connected mode#

ITables use two Javascript libraries: jQuery and DataTables.

By default itables works offline. No internet connection is required as the two libraries are embedded into the notebook itself when you execute init_notebook_mode.

In some contexts (Jupyter Book, Jupyter 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 700kB.

Try ITables on Binder#

You can run the examples above (or any other documentation page) directly on Lab, without having to install anything on your end - just click on the rocket icon at the top of the page.

Licence#

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.