Quick Start#
Turn your Python DataFrames into Interactive Tables#
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).
Installation#
Install the itables
package with either
pip install itables
or
conda install itables -c conda-forge
Activate ITables#
Activate the interactive mode for all series and dataframes with
from itables import init_notebook_mode
init_notebook_mode(all_interactive=True)
After this, any Pandas or Polars DataFrame, or Series, is displayed as an interactive datatables.net table, which lets you explore, filter or sort your data.
from itables.sample_dfs import get_countries
df = get_countries(html=False)
df
region | country | capital | longitude | latitude | |
---|---|---|---|---|---|
code | |||||
Loading... (need help?) |
Offline mode versus connected mode#
ITables use two Javascript libraries: jquery and datatables.net.
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.
Formatting specific tables only#
If you prefer to render only certain series or dataframes using itables
,
or you want to use the advanced parameters, then
use init_notebook_mode(all_interactive=False)
then show
:
from itables import show
show(df, lengthMenu=[2, 5, 10, 25, 50, 100, 250])
region | country | capital | longitude | latitude | |
---|---|---|---|---|---|
code | |||||
Loading... (need help?) |
HTML content#
HTML content is supported, which means that you can have formatted text, links or even images in your tables:
df["flag"] = [
'<a href="https://flagpedia.net/{code}">'
'<img src="https://flagpedia.net/data/flags/h80/{code}.webp" '
'alt="Flag of {country}"></a>'.format(code=code.lower(), country=country)
for code, country in zip(df.index, df["country"])
]
df["country"] = [
'<a href="https://en.wikipedia.org/wiki/{}">{}</a>'.format(country, country)
for country in df["country"]
]
df["capital"] = [
'<a href="https://en.wikipedia.org/wiki/{}">{}</a>'.format(capital, capital)
for capital in df["capital"]
]
df
region | country | capital | longitude | latitude | flag | |
---|---|---|---|---|---|---|
code | ||||||
Loading... (need help?) |
Try ITables on Binder#
You can run our examples notebooks directly on , without having to install anything on your side.