Pandas DataFrames are central to Data Analysis in Python. In this post, we introduce the itables
Python package that enhances how these DataFrames are displayed, by turning them into interactive HTML DataTables.
Using itables
is as simple as
from itables import init_notebook_mode
init_notebook_mode(all_interactive=True)
Then every DataFrame will appear as an interactive table:
import world_bank_data as wb
df = wb.get_countries()
df
Of course, you can use itables
for selected tables only, in that case, you'll do
from itables import init_notebook_mode, show
init_notebook_mode(all_interactive=False)
show(df)
Our package is a thin wrapper on datatables.net (just like DT which inspired itables
). Almost all the formatting options of datatables.net are available in itables
- pass them to the show
function or set them globally in itables.options
, as documented in our README (try it on Binder).
Using itables
has the following advantages:
- You can explore, scroll, sort and even filter the table interactively
- The interactive table takes less vertical space than the default Pandas representation
- The full dataset is embedded in the table, not only 100 rows (for tables above 64KB a down-sampling is applied, but you can increase that threshold)
- ⭐New in
itables>=0.4.0
⭐ It works in all the notebooks editors we have tested: Jupyter Notebook, Lab, Colab, VS Code, PyCharm - And the interactive tables also work when the notebook is exported as an HTML file (with
jupyter nbconvert
or Download as HTML)
The itables
package was created by Marc Wouts in 2019. In the recent weeks, with the release of itables>=0.4.0
, we finally solved the issue of making it work in Jupyter Lab and other editors. Marc would like to thank François Wouts for his precious help on transitioning to ES modules, and Allan Jardine, the author of datatables.net, for his support on the datatables.net forum.
A few other packages that let you explore your DataFrames interactively are
- D-Tale by Man Group. D-Tale uploads the DataFrames from your notebook to a local server, and provides interactive tables and data visualizations in another tab of the browser
- ipysheet by QuantStack, a wrapper for Handsontable
- QGrid by Quantopian, a Python wrapper for SlickGrid (last released Apr. 2020)
- ipyaggrid by Louis Raison and Olivier Borderies.
Unlike the above packages, itables
does not require a live kernel (use voila if you need one). The table data is simply embedded in the notebook outputs, and for this reason, the HTML export of an itables
notebook just works.
Please let us know how itables
works for you. Your contributions are welcome! Star the project on GitHub, report your issues, or even join forces for building an offline mode or supporting the datatables extensions!