• Stars
    star
    757
  • Rank 59,989 (Top 2 %)
  • Language
    Jupyter Notebook
  • License
    MIT License
  • Created over 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pandas DataFrames as Interactive DataTables

Interactive Tables

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

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 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.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.

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)

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

More Repositories

1

jupytext

Jupyter Notebooks as Markdown Documents, Julia, Python or R scripts
Python
6,064
star
2

world_bank_data

The World Bank Data in Python
Python
110
star
3

jupyterlab-jupytext

A JupyterLab extension for Jupytext
TypeScript
25
star
4

notebooks_in_vscode_and_pycharm_jan_2020

Working with Jupyter Notebooks in Visual Studio Code and PyCharm (January 2020)
22
star
5

papermill_jupytext

Parametrize and run scripts as notebooks with jupytext and papermill
Python
15
star
6

world_trade_data

World Integrated Trade Solution (WITS) API in Python
HTML
15
star
7

jupytext_pyparis_2018

Jupytext talk at PyParis 2018
Jupyter Notebook
11
star
8

easyplotly

Hopefully makes it easier to produce complex plots with Plotly
Python
6
star
9

ipython_from_R

Communicate with jupyter kernels from R
Python
6
star
10

resize_encrypted_partitions

How to Resize Bitlocker and LUKS Encrypted Partitions
4
star
11

plotly_offline_export

Offline export of plotly plots
Python
4
star
12

flocon

Le Flocon de Koch, de la programmation 2D avec Scratch à l'impression 3D avec OpenSCAD
OpenSCAD
4
star
13

github_actions_python

Testing your Python Project with GitHub Actions
4
star
14

jupyterlab-itables-toggle-wip

A JupyterLab extension for ITables
Python
3
star
15

jupytext_nbextension

A Jupyter notebook extension for Jupytext
JavaScript
3
star
16

sortpics

Pictures from Google Photos, ICloud, or your Camera... all sorted!
Python
3
star
17

notebooks

Jupyter Notebook
3
star
18

nbsrc

Python and R scripts as Jupyter notebooks
Jupyter Notebook
3
star
19

nbpercent

Jupyter Notebooks as Scripts with Outputs
Python
2
star
20

elegant-scipy-as-a-jp-book

Elegant Scipy as a Jupyter Book (EXPERIMENTAL)
HTML
2
star
21

test_miniconda_action

1
star
22

jupyter-book-experiments

Deploy pre-existing Markdown and R Markdown books with Jupyter Book
Shell
1
star