Skip to content

Commit 61eb94b

Browse files
committed
Update the documentation
Install the widget dependencies Move the row selection to a new chapter
1 parent b6c9959 commit 61eb94b

File tree

5 files changed

+94
-42
lines changed

5 files changed

+94
-42
lines changed

.github/workflows/publish-book.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
pip install jupyter-book
3131
pip install matplotlib # Pandas style
3232
pip install .[polars]
33+
pip install .[widget]
3334
3435
- name: Create a kernel
3536
run: |

docs/_toc.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@ parts:
44
- caption: ITables in Notebooks
55
chapters:
66
- file: advanced_parameters
7+
- file: select
8+
- file: extensions
9+
- file: custom_extensions
710
- file: custom_css
811
- file: formatting
912
- file: pandas_style
10-
- file: extensions
11-
- file: custom_extensions
1213
- file: dark_mode
1314
- file: quarto
1415
- file: downsampling
1516
- file: references
1617
- file: supported_editors
1718
- caption: ITables in Applications
1819
chapters:
19-
- file: html_export
20-
- file: dash
21-
- file: shiny
22-
- file: streamlit
2320
- file: ipywidgets
21+
- file: streamlit
22+
- file: shiny
23+
- file: dash
24+
- file: html_export
2425
- caption: Contributing to ITables
2526
chapters:
2627
- file: contributing

docs/extensions.md

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ show(
105105
```{tip}
106106
Only the filtered or selected rows are exported to CSV/Excel. To filter the rows you
107107
can use the simple search box, the [SearchPanes](#searchpanes) and [SearchBuilder](#searchbuilder)
108-
options, or the [select](#row-selection) extension.
108+
options, or the [select](select.md) extension.
109109
```
110110

111111
```{warning}
@@ -261,40 +261,6 @@ opt.keys = True
261261
The KeyTable extension works in Jupyter Book (try it here in the documentation) but not in JupyterLab.
262262
```
263263

264-
## Row selection
265-
266-
The [select](https://datatables.net/extensions/select) extension let you select rows (or cells). When you do so,
267-
only the selected rows are exported
268-
269-
```{code-cell}
270-
:tags: [full-width]
271-
272-
show(
273-
df,
274-
select=True,
275-
selected_rows=[2, 4, 5],
276-
buttons=["copyHtml5", "csvHtml5", "excelHtml5"],
277-
)
278-
```
279-
280-
```{tip}
281-
The `select` option accept multiple values, as documented [here](https://datatables.net/extensions/select):
282-
- `select=True` or `select="os"` let you select using single click, shift-click and ctrl-click
283-
- `select="single"` let you select a single row
284-
- `select="multi"` for single click selection of multiple rows, `select="multi+shift"`, ...
285-
286-
With `select={"style": "os", "items": "cell"}` you can let the user select specific cells,
287-
however cell selection is not taken into account when exporting the data.
288-
```
289-
290-
```{tip}
291-
It is possible to get the updated `selected_rows` back in Python but for this you will have to use,
292-
instead of `show`, either
293-
- the `ITable` [Jupyter Widget](ipywidgets.md)
294-
- the `interactive_table` [Streamlit component](streamlit.md)
295-
- or `DT` in a [Shiny app](shiny.md).
296-
```
297-
298264
## RowGroup
299265

300266
Use the [RowGroup](https://datatables.net/extensions/rowgroup/) extension to group

docs/ipywidgets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ table
4040
## The `selected_rows` traits
4141

4242
The `selected_rows` attribute of the `ITable` object provides a view on the
43-
rows that have been selected in the table (remember to pass `select=True`
43+
rows that have been selected in the table (remember to pass [`select=True`](select.md)
4444
to activate the row selection). You can use it to either retrieve
4545
or change the current row selection:
4646

docs/select.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
jupytext:
3+
formats: md:myst
4+
notebook_metadata_filter: -jupytext.text_representation.jupytext_version
5+
text_representation:
6+
extension: .md
7+
format_name: myst
8+
format_version: 0.13
9+
kernelspec:
10+
display_name: itables
11+
language: python
12+
name: itables
13+
---
14+
15+
## Row selection
16+
17+
The [select](https://datatables.net/extensions/select) extension let you select rows (or cells). When you do so,
18+
only the selected rows are exported
19+
20+
```{code-cell}
21+
from itables import init_notebook_mode, show
22+
23+
init_notebook_mode()
24+
```
25+
26+
```{code-cell}
27+
:tags: [hide-input]
28+
29+
import string
30+
31+
import numpy as np
32+
import pandas as pd
33+
34+
from itables.sample_dfs import get_countries
35+
36+
df = get_countries(html=False)
37+
# Add columns for the searchPanes demo
38+
df["climate_zone"] = np.where(
39+
df["latitude"].abs() < 23.43615,
40+
"Tropical",
41+
np.where(
42+
df["latitude"].abs() < 35,
43+
"Sub-tropical",
44+
# Artic circle is 66.563861 but there is no capital there => using 64
45+
np.where(df["latitude"].abs() < 64, "Temperate", "Frigid"),
46+
),
47+
)
48+
df["hemisphere"] = np.where(df["latitude"] > 0, "North", "South")
49+
wide_df = pd.DataFrame(
50+
{
51+
letter: np.random.normal(size=100)
52+
for letter in string.ascii_lowercase + string.ascii_uppercase
53+
}
54+
)
55+
```
56+
57+
```{code-cell}
58+
:tags: [full-width]
59+
60+
show(
61+
df,
62+
select=True,
63+
selected_rows=[2, 4, 5],
64+
buttons=["copyHtml5", "csvHtml5", "excelHtml5"],
65+
)
66+
```
67+
68+
```{tip}
69+
It is possible to get the updated `selected_rows` back in Python but for this you will have to use,
70+
instead of `show`, either
71+
- the `ITable` [Jupyter Widget](ipywidgets.md)
72+
- the `interactive_table` [Streamlit component](streamlit.md)
73+
- or `DT` in a [Shiny app](shiny.md).
74+
```
75+
76+
```{tip}
77+
The `select` option accept multiple values, as documented [here](https://datatables.net/extensions/select):
78+
- `select=True` or `select="os"` let you select using single click, shift-click and ctrl-click
79+
- `select="single"` let you select a single row
80+
- `select="multi"` for single click selection of multiple rows, `select="multi+shift"`, ...
81+
82+
With `select={"style": "os", "items": "cell"}` you can let the user select specific cells,
83+
however cell selection is not taken into account when exporting the data.
84+
```

0 commit comments

Comments
 (0)