Skip to main content

Pandas and Polar DataFrames as interactive DataTables

Project description

Interactive Tables

CI codecov.io Pypi Conda Version pyversions Code style: black

Turn your Python DataFrames into Interactive DataTables

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 only depends 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).

Documentation

Browse the documentation to see examples of Pandas or Polars DataFrames rendered as interactive DataTables.

Quick start

Install the itables package with either

pip install itables

or

conda install itables -c conda-forge

Activate the interactive mode for all series and dataframes with

from itables import init_notebook_mode

init_notebook_mode(all_interactive=True)

and then render any DataFrame as an interactive table that you can sort, search and explore: df

If you prefer to render only selected DataFrames as interactive tables, use itables.show to show just one Series or DataFrame as an interactive table: show

Since itables==1.0.0, the jQuery and DataTables 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.

Supported environments

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)
  • Quarto
  • Shiny for Python

Try ITables on Binder

You can run our examples notebooks directly on Lab, without having to install anything on your side.

Table not loading?

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.

Downsampling

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
from itables.downsample import nbytes
import itables.options as opt

opt.lengthMenu = [2, 5, 10, 20, 50, 100, 200, 500]
opt.maxBytes = 10000

df = get_indicators()
nbytes(df)
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

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

itables-2.0.0rc5.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

itables-2.0.0rc5-py3-none-any.whl (215.6 kB view details)

Uploaded Python 3

File details

Details for the file itables-2.0.0rc5.tar.gz.

File metadata

  • Download URL: itables-2.0.0rc5.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for itables-2.0.0rc5.tar.gz
Algorithm Hash digest
SHA256 3a1b2d8ddabf9375a4ae5051478db2d3fa435527715fba94aa75e3b53a92ca58
MD5 06ba5183b8891cf591bc66c721febeaf
BLAKE2b-256 7d1a363a9e30154ffbda66945ae7f0377bf5b9bd724a266315079a7364748b16

See more details on using hashes here.

File details

Details for the file itables-2.0.0rc5-py3-none-any.whl.

File metadata

  • Download URL: itables-2.0.0rc5-py3-none-any.whl
  • Upload date:
  • Size: 215.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for itables-2.0.0rc5-py3-none-any.whl
Algorithm Hash digest
SHA256 01e9f983f819e6dd752b49f8d6dad70f03b346e3fdd8279a64719a33d9c2da27
MD5 877d78cd1728f9a05f76848e886e0aef
BLAKE2b-256 ca679b8e1f0ff25ab51eaf8082dadf1f55ec1a8e3576385bb974d77fb7dabd2e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page