Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Narwhals to support Polars and Modin DataFrames #341

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 40 additions & 17 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,35 @@ jobs:
uses: github/codeql-action/analyze@v3

pytest:
name: >
${{ matrix.python-version }}
${{ matrix.pandas-version && format('(pandas {0})', matrix.pandas-version)}}
${{ matrix.numpy-version && format('(numpy {0})', matrix.numpy-version)}}
${{ matrix.modifiers}}
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
pandas-version: [latest]
numpy-version: [latest]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
pandas-version: ['']
numpy-version: ['']
modifiers: ['']
include:
- python-version: 3.7
pandas-version: '<1.0'
- python-version: 3.9
- python-version: 3.9
pandas-version: '<2.0'
numpy-version: '<2.0'
- python-version: "3.13"
pandas-version: pre
polars: true
- python-version: "3.13"
uninstall_jinja2: true
modifiers: "polars"
- python-version: "3.13"
modifiers: "ibis"
- python-version: "3.12"
modifiers: "modin"
- python-version: "3.13"
modifiers: "uninstall_narwhals"
- python-version: "3.13"
modifiers: "uninstall_jinja2"
runs-on: ubuntu-20.04
steps:
- name: Checkout
Expand All @@ -70,31 +82,42 @@ jobs:
- name: Install a development version of 'itables'
run: pip install -e .[test]

- name: Install pandas latest
if: matrix.pandas-version == 'latest'
- name: Install latest pandas
if: ${{!matrix.pandas-version}}
run: pip install pandas
- name: Install pandas pre-release
if: matrix.pandas-version == 'pre'
run: pip install pandas --pre
- name: Install pandas ${{ matrix.pandas-version }}
if: matrix.pandas-version != 'pre' && matrix.pandas-version != 'latest'
if: matrix.pandas-version && matrix.pandas-version != 'pre'
run: pip install 'pandas${{ matrix.pandas-version }}'
- name: Install numpy ${{ matrix.numpy-version }}
if: matrix.numpy-version != 'latest'
if: matrix.numpy-version
run: pip install 'numpy${{ matrix.numpy-version }}'

- name: Install polars
if: matrix.polars
run: pip install -e .[polars]
if: matrix.modifiers == 'polars'
run: pip install polars

- name: Install shiny
if: matrix.python-version != '3.7'
run: pip install "shiny>=1.0"
- name: Install ibis
if: matrix.modifiers == 'ibis'
run: pip install 'ibis-framework[duckdb]'

- name: Install modin
if: matrix.modifiers == 'modin'
run: pip install modin[all]

- name: Uninstall narwhals
if: matrix.modifiers == 'uninstall_narwhals'
run: pip uninstall narwhals -y

- name: Uninstall jinja2
if: matrix.uninstall_jinja2
if: matrix.modifiers == 'uninstall_jinja2'
run: pip uninstall jinja2 -y

- name: Install shiny
run: pip install "shiny>=1.0"

- name: Install a Jupyter Kernel
run: python -m ipykernel install --name itables --user

Expand Down
1 change: 1 addition & 0 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ parts:
chapters:
- file: sample_dataframes
- file: polars_dataframes
- file: modin_dataframes
7 changes: 7 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
ITables ChangeLog
=================

2.3.0-dev
---------

**Added**
- In addition to Pandas and Polars, ITables now support Modin DataFrames ([#325](https://github.com/mwouts/itables/issues/325)). Under the hoods we use [Narwhals](https://github.com/narwhals-dev/narwhals) to handle the different types of DataFrames. Thanks to [Dea María Léon](https://github.com/DeaMariaLeon) and to [Marco Gorelli](https://github.com/MarcoGorelli) for making this work, and for developing Narwhals too!


2.2.4 (2024-12-07)
------------------

Expand Down
183 changes: 183 additions & 0 deletions docs/ibis_dataframes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
---
jupytext:
formats: md:myst
notebook_metadata_filter: -jupytext.text_representation.jupytext_version
text_representation:
extension: .md
format_name: myst
format_version: 0.13
kernelspec:
display_name: itables
language: python
name: itables
---

# Sample dataframes

In this notebook we make sure that our test [Ibis](https://ibis-project.org/) dataframes are displayed nicely with the default `itables` settings.

```{code-cell}
from itables import init_notebook_mode, show
from itables.sample_dfs import get_dict_of_test_ibis_dfs

dict_of_test_dfs = get_dict_of_test_ibis_dfs()
init_notebook_mode(all_interactive=True)
```

## empty

```{code-cell}
show(dict_of_test_dfs["empty"])
```

## No rows

```{code-cell}
show(dict_of_test_dfs["no_rows"])
```

## No rows one column

```{code-cell}
show(dict_of_test_dfs["no_rows_one_column"])
```

## No columns

```{code-cell}
show(dict_of_test_dfs["no_columns"])
```

## No columns one row

```{code-cell}
show(dict_of_test_dfs["no_columns_one_row"])
```

## bool

```{code-cell}
show(dict_of_test_dfs["bool"])
```

## Nullable boolean

```{code-cell}
show(dict_of_test_dfs["nullable_boolean"])
```

## int

```{code-cell}
show(dict_of_test_dfs["int"])
```

## Nullable integer

```{code-cell}
show(dict_of_test_dfs["nullable_int"])
```

## float

```{code-cell}
show(dict_of_test_dfs["float"])
```

## str

```{code-cell}
show(dict_of_test_dfs["str"])
```

## time

```{code-cell}
show(dict_of_test_dfs["time"])
```

## object

```{code-cell}
show(dict_of_test_dfs["object"])
```

## ordered_categories

```{code-cell}
show(dict_of_test_dfs["ordered_categories"])
```

## ordered_categories_in_multiindex

```{code-cell}
show(dict_of_test_dfs["ordered_categories_in_multiindex"])
```

## multiindex

```{code-cell}
show(dict_of_test_dfs["multiindex"])
```

## countries

```{code-cell}
:tags: [full-width]

show(dict_of_test_dfs["countries"])
```

## capital

```{code-cell}
show(dict_of_test_dfs["capital"])
```

## complex_index

```{code-cell}
:tags: [full-width]

show(dict_of_test_dfs["complex_index"])
```

## int_float_str

```{code-cell}
show(dict_of_test_dfs["int_float_str"])
```

## wide

```{code-cell}
:tags: [full-width]

show(dict_of_test_dfs["wide"], maxBytes=100000, maxColumns=100, scrollX=True)
```

## long_column_names

```{code-cell}
:tags: [full-width]

show(dict_of_test_dfs["long_column_names"], scrollX=True)
```

## duplicated_columns

```{code-cell}
show(dict_of_test_dfs["duplicated_columns"])
```

## named_column_index

```{code-cell}
show(dict_of_test_dfs["named_column_index"])
```

## big_integers

```{code-cell}
show(dict_of_test_dfs["big_integers"])
```
Loading
Loading