Pandas DataFrames and Series as interactive datatables!
Install the package with
pip install itables
Activate the interactive mode for all series and dataframes with
from itables import init_notebook_mode
init_notebook_mode(all_interactive=True)
or use itables.show
to show just one Series or DataFrame as an interactive table.
Since itables==1.0.0
, the jquery and datatables.net libraries and CSS
are injected in the notebook when you execute init_notebook_mode
with its default argument connected=False
.
Thanks to this the interactive tables will work even without a connection to the internet.
If you prefer to load the libraries dynamically (and keep the notebook lighter), use connected=True
when you
execute init_notebook_mode
.
Read more about itables
and advanced use cases in the documentation.
In particular, the show
method let you pass custom parameters to datatables.net's DataTable()
's constructor - see the advanced parameters examples.
itables
has been tested in the following editors:
- Jupyter Notebook
- Jupyter Lab
- Jupyter nbconvert (i.e. the tables are still interactive in the HTML export of a notebook)
- Jupyter Book
- Google Colab
- VS Code (for both Jupyter Notebooks and Python scripts)
- PyCharm (for Jupyter Notebooks)
You can run our examples notebooks directly on , without having to install anything on your side.
If the table just says "Loading...", then maybe
- You loaded a notebook that is not trusted (run "Trust Notebook" in View / Activate Command Palette)
- You forgot to run
init_notebook_mode
, or you deleted that cell or its output - Or you ran
init_notebook_mode(connected=True)
but you are not connected to the internet?
Please note that if you change the value of the connected
argument in
the init_notebook_mode
cell, you will need to re-execute all the cells
that display interactive tables.
If the above does not help, please check out the ChangeLog
and decide whether you should upgrade itables
.
When the data in a table is larger than maxBytes
, which is equal to 64KB by default, itables
will display only a subset of the table - one that fits into maxBytes
. If you wish, you can deactivate the limit with maxBytes=0
, change the value of maxBytes
, or similarly set a limit on the number of rows (maxRows
, defaults to 0) or columns (maxColumns
, defaults to pd.get_option('display.max_columns')
).
Note that datatables support server-side processing. At a later stage we may implement support for larger tables using this feature.
from itables.sample_dfs import get_indicators
import itables.options as opt
opt.lengthMenu = [2, 5, 10, 20, 50, 100, 200, 500]
opt.maxBytes = 10000
df = get_indicators()
df.values.nbytes
df
To show the table in full, we can modify the value of maxBytes
either locally:
show(df, maxBytes=0)
or globally:
opt.maxBytes = 2 ** 20
df