Pandas DataFrames and Series as Interactive Tables in Jupyter

Pypi Build Status codecov.io Binder Star

Turn pandas DataFrames and Series into interactive datatables in both your notebooks and their HTML representation with import itables.interactive:

Quick start

Install the package with

pip install itables

Activate the interactive mode for all series and dataframes with

You don't see any table above? Please either open the HTML export of this notebook, or run this README on Binder!

Or display just one series or dataframe as an interactive table with the show function.

Advanced usage

Pagination

How many rows per page

Select how many entries should appear at once in the table with either the lengthMenu argument of the show function, or with the global option itables.options.lengthMenu:

Show the table in full

Show the table in full with the paging argument, either in the show method, or in the options:

Scroll

If you prefer to replace the pagination with a vertical scroll, use for instance

Table and cell style

Select how your table should look like with the classes argument of the show function, or by changing itables.options.classes. For the list of possible values, see datatables' default style and the style examples.

Float precision

Floats are rounded using pd.options.display.float_format. Please change that format according to your preference.

You may also choose to convert floating numbers to strings:

Advanced cell formatting

Datatables allows to set the cell or row style depending on the cell content, with either the createdRow or createdCell callback. For instance, if we want the cells with negative numbers to be colored in red, we can use the columnDefs.createdCell argument as follows:

Column width

For tables that are larger than the notebook, the columnDefs argument allows to specify the desired width. If you wish you can also change the default in itables.options.

HTML in cells

Select rows

Not currently implemented. May be made available at a later stage using the select extension for datatables.

Copy, CSV, PDF and Excel buttons

Not currently implemented. May be made available at a later stage thanks to the buttons extension for datatable.

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.

To show the table in full, we can modify the value of maxBytes either locally:

or globally:

References

DataTables

Alternatives

ITables uses basic Javascript, and because of this it will only work in Jupyter Notebook, not in JupyterLab. It is not a Jupyter widget, which means that it does not allows you to edit the content of the dataframe.

If you are looking for Jupyter widgets, have a look at

If you are looking for a table component that will fit in Dash applications, see datatable by Dash.

Contributing

I think it would be very helpful to have an identical table component for both Jupyter and Dash. Please let us know if you are interested in drafting a new table component based on an existing Javascript library for Dash.

Also, if you happen to prefer another Javascript table library (say, ag-grid), and you would like to see it supported in itables, please open either an issue or a PR, and let us know what is the minimal code to display a table in Jupyter using your library.