Skip to main content

A set of widgets to help facilitate reuse of large tables across widgets

Project description

ipytablewidgets

Python tests

Typescript tests

End to end tests

NB: End to end tests use Galata framework.

Traitlets and widgets to efficiently data tables (e.g. Pandas DataFrame) using the jupyter notebook

ipytablewidgets is a set of widgets and traitlets to reuse of large tables such as Pandas DataFrames across different widgets, and different packages.

Installation

Using pip:

pip install ipytablewidgets

Development installation

The first step requires the following three commands to be run (requires yarn and jupyterlab>=3):

$ git clone https://github.com/progressivis/ipytablewidgets.git
$ cd ipytablewidgets
$ pip install -e .

The development of extensions for jupyter notebook and jupyter lab requires JavaScript code to be modified in-place. For this reason, lab and notebook extensions need to be configured this way:

  • For jupyter notebook:
    $ jupyter nbextension install --py --overwrite --symlink --sys-prefix ipytablewidgets
    $ jupyter nbextension enable --py --sys-prefix ipytablewidgets
    
  • For jupyter lab:
    $ jupyter labextension develop . --overwrite
    

Tables

The main widget for tables is the TableWidget class. It has a main trait: A table. This table's main purpose is simply to be a standardized way of transmitting table data from the kernel to the frontend, and to allow the data to be reused across any number of other widgets, but with only a single sync across the network.

import pandas as pd
from ipytableidgets import TableWidget, PandasAdapter, serialization

@widgets.register
class MyWidget(DOMWidget):
    """
    My widget needing a table
    """
    _view_name = Unicode('MyWidgetView').tag(sync=True)
    _model_name = Unicode('MyWidgetModel').tag(sync=True)
    ...
    data = Instance(TableWidget).tag(sync=True, **serialization)
    def __init__(self, wg, **kwargs):
        self.data = wg
        super().__init__(**kwargs)

df = pd.DataFrame({'a': [1,2], 'b': [3.5, 4.5], 'c': ['foo','bar'])
table_widget = TableWidget(PandasAdapter(df))
my_widget = MyWidget(table_widget)

You can see EchoTableWidget which is a more realistic example, currently used for end to end testing and demo.

Or, if you prefer to use the TableType traitlet directly:

from ipytablewidgets import serialization, TableType

@widgets.register
class MyWidget(DOMWidget):
    """
    My widget needing a table
    """
    ...
    data = TableType(None).tag(sync=True, **serialization)

Developers

Developers should consider using ipytablewidgets because:

  • It gives readily accessible syncing of table data using the binary transfer protocol of ipywidgets.
  • It gives compression methods speifically suited for columnar data.
  • It avoids duplication of common code among different extensions, ensuring that bugs discovered for one extension gets fixed in all.

Overview

The major parts of ipyablewidgets are:

  • Traits/Widgets definitions
  • Adapters to convert tables to those traits
  • Serializers/deserializers to send the data across the network
  • Apropriate javascript handling and representation of the data

Project details


Download files

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

Source Distribution

ipytablewidgets-0.1.1.tar.gz (199.0 kB view details)

Uploaded Source

Built Distribution

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

ipytablewidgets-0.1.1-py2.py3-none-any.whl (184.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ipytablewidgets-0.1.1.tar.gz.

File metadata

  • Download URL: ipytablewidgets-0.1.1.tar.gz
  • Upload date:
  • Size: 199.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for ipytablewidgets-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7eae484db0a7b4549807b6c481305db09511b06ccb22be350379f252af37bdbc
MD5 a3f0de658eb7c5f3fe0fa134c36f7b60
BLAKE2b-256 a98984c215e4189499bbafff0d94770438a4d320b3df314c25943a206cf6c4aa

See more details on using hashes here.

File details

Details for the file ipytablewidgets-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: ipytablewidgets-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 184.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for ipytablewidgets-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 60e5ea2f3939a8d87bce3738bbc027025b65916fcd38ad34e0d8d8a2f69da0d8
MD5 560eb666e9547bd6ed9ddcc32eb74c63
BLAKE2b-256 0a140b624ed9fcc089a77b4f01a898c20b89ddeada56dde17e07e947efca8207

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