Skip to content

Commit

Permalink
ITables Version 2.0 (#235)
Browse files Browse the repository at this point in the history
* Bundle DataTables and a few extensions using esbuild
* Remove the css option and document the styling
* export big integers as bigint in JS
* Transition to hatch and pyproject.toml
* Add support for Python 3.12
  • Loading branch information
mwouts committed Mar 16, 2024
1 parent a970712 commit 73e6fa4
Show file tree
Hide file tree
Showing 48 changed files with 1,555 additions and 737 deletions.
57 changes: 35 additions & 22 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,59 +17,56 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0
uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1

codeql:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: python, javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3

pytest:
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11"]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
pandas-version: [latest]
include:
- python-version: 3.6
pandas-version: 0.22
- python-version: 3.7
pandas-version: '<1.0'
- python-version: 3.9
pandas-version: 1.5
- python-version: "3.11"
pandas-version: '<2.0'
- python-version: "3.12"
pandas-version: pre
polars: true
- python-version: "3.11"
- python-version: "3.12"
uninstall_jinja2: true
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Install a development version of 'itables'
run: pip install -e .
run: pip install -e .[test]

- name: Install pandas latest
if: matrix.pandas-version == 'latest'
Expand All @@ -79,7 +76,7 @@ jobs:
run: pip install pandas --pre
- name: Install pandas ${{ matrix.pandas-version }}
if: matrix.pandas-version != 'pre' && matrix.pandas-version != 'latest'
run: pip install pandas==${{ matrix.pandas-version }}
run: pip install 'pandas${{ matrix.pandas-version }}'

- name: Install polars
if: matrix.polars
Expand All @@ -97,3 +94,19 @@ jobs:

- name: Upload coverage
uses: codecov/codecov-action@v3

build:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install hatch
run : pip install hatch
- name: Build package
run: hatch build
8 changes: 5 additions & 3 deletions .github/workflows/publish-book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ jobs:
deploy-book:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4

# Install dependencies
- name: Set up Python 3.11
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: 3.11

Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@ on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+dev[0-9]+"

jobs:
publish:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/jupytext
url: https://pypi.org/p/itables
permissions:
id-token: write
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: 3.11
- name: Build package
run: |
pip install wheel requests
python setup.py sdist bdist_wheel
python -m pip install wheel build
python -m build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ dist
# Jupyter Book
_build

# External dependencies
itables/external

# Quarto
.jupyter_cache
docs/quarto/*.html
docs/quarto/*_files/

# DataTables bundle
node_modules
dt_bundle.js
dt_bundle.css
20 changes: 12 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,31 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8

- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/psf/black
rev: 23.1.0
rev: 22.3.0
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.1
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]

- repo: https://github.com/mwouts/jupytext
rev: v1.14.5
hooks:
- id: jupytext
exclude: dt_for_itables/
types: ["markdown"]
args: ["--pipe", "black"]
args: ["--pipe", "isort {} --treat-comment-as-code '# %%' --profile black", "--pipe", "black", "--check", "ruff check {} --ignore E402"]
additional_dependencies:
- black==22.3.0 # Matches hook
- ruff==0.3.1
- isort==5.13.2
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

![CI](https://github.com/mwouts/itables/actions/workflows/continuous-integration.yml/badge.svg?branch=main)
[![codecov.io](https://codecov.io/github/mwouts/itables/coverage.svg?branch=main)](https://codecov.io/github/mwouts/itables?branch=main)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/mwouts/itables.svg)](https://lgtm.com/projects/g/mwouts/itables/context:python)
[![Pypi](https://img.shields.io/pypi/v/itables.svg)](https://pypi.python.org/pypi/itables)
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/itables.svg)](https://anaconda.org/conda-forge/itables)
[![pyversions](https://img.shields.io/pypi/pyversions/itables.svg)](https://pypi.python.org/pypi/itables)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

## Turn your Python DataFrames into Interactive Tables
## 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](https://datatables.net/)
With `itables` you can display your tables as interactive [DataTables](https://datatables.net/)
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,
Expand All @@ -24,7 +23,7 @@ work with Polars DataFrames).
## Documentation

Browse the [documentation](https://mwouts.github.io/itables/) to see
examples of Pandas or Polars DataFrames rendered as interactive datatables.
examples of Pandas or Polars DataFrames rendered as interactive DataTables.

## Quick start

Expand All @@ -50,7 +49,7 @@ and then render any DataFrame as an interactive table that you can sort, search
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](docs/show_df.png)

Since `itables==1.0.0`, the [jquery](https://jquery.com/) and [datatables.net](https://datatables.net/) libraries and CSS
Since `itables==1.0.0`, the [jQuery](https://jquery.com/) and [DataTables](https://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.

Expand All @@ -67,6 +66,8 @@ execute `init_notebook_mode`.
- Google Colab
- VS Code (for both Jupyter Notebooks and Python scripts)
- PyCharm (for Jupyter Notebooks)
- Quarto
- Shiny for Python

## Try ITables on Binder

Expand All @@ -90,7 +91,7 @@ and decide whether you should upgrade `itables`.

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](https://datatables.net/examples/data_sources/server_side). At a later stage we may implement support for larger tables using this feature.
Note that DataTables support [server-side processing](https://datatables.net/examples/data_sources/server_side). At a later stage we may implement support for larger tables using this feature.

```{code-cell}
from itables.sample_dfs import get_indicators
Expand Down
1 change: 1 addition & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
title: Interactive Tables
author: Marc Wouts
copyright: "2019-2024"
execute:
execute_notebooks: force
sphinx:
Expand Down
37 changes: 23 additions & 14 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
format: jb-book
root: quick_start
chapters:
- file: supported_editors
- file: advanced_parameters
- file: pandas_style
- file: custom_css
- file: downsampling
- file: sample_dataframes
- file: polars_dataframes
- file: quarto
- file: references
- file: contributing
- file: developing
- file: troubleshooting
- file: changelog
parts:
- caption: How to use DataTables
chapters:
- file: advanced_parameters
- file: formatting
- file: custom_css
- file: extensions
- file: custom_extensions
- caption: ITables
chapters:
- file: supported_editors
- file: quarto
- file: downsampling
- file: references
- file: contributing
- file: developing
- file: troubleshooting
- file: changelog
- caption: Example DataFrames
chapters:
- file: sample_dataframes
- file: polars_dataframes
- file: pandas_style

0 comments on commit 73e6fa4

Please sign in to comment.