Skip to content

Commit e6fb0d5

Browse files
committed
Use full width, update examples
1 parent db70324 commit e6fb0d5

File tree

8 files changed

+51
-41
lines changed

8 files changed

+51
-41
lines changed

docs/apps/notebook.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ kernelspec:
1212
name: itables
1313
---
1414

15+
```{code-cell} ipython3
16+
:tags: [remove-cell]
17+
18+
# pyright: reportUnusedExpression=false
19+
```
20+
1521
# Notebook Mode
1622

1723
Activate ITables in a Jupyter environment for all your tables with `init_notebook_mode`:
@@ -24,6 +30,13 @@ itables.init_notebook_mode()
2430

2531
You can go back to the standard HTML representation of Pandas DataFrames with `init_notebook_mode(all_interactive=False)`.
2632

33+
```{code-cell} ipython3
34+
:tags: [full-width]
35+
36+
df = itables.sample_dfs.get_countries(html=False)
37+
df
38+
```
39+
2740
Note that the `init_connected_mode` function also activates ITable's offline mode, unless you call it with a `connected=False` argument.
2841

2942

@@ -42,15 +55,7 @@ about [700kB](https://github.com/mwouts/itables/blob/main/tests/test_connected_n
4255
If you prefer to render only certain tables using `itables`, or want to set additional options, use `show`:
4356

4457
```{code-cell} ipython3
45-
df = itables.sample_dfs.get_countries(html=False)
58+
:tags: [full-width]
4659
47-
itables.show(
48-
df,
49-
caption="A DataFrame rendered with ITables",
50-
lengthMenu=[2, 5, 10, 25, 50, 100, 250],
51-
)
60+
itables.show(df, caption="A DataFrame rendered with ITables")
5261
```
53-
54-
## HTML
55-
56-
The `show` function simply displays the HTML snippet for the table, which is obtained with `to_html_datatable`. See more in the section on [HTML export](html.md).

docs/downsampling.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ kernelspec:
2020

2121
# Downsampling
2222

23-
When an interactive table is displayed by `itables`, the table data is embedded in the notebook output. As we don't want your notebook to become super heavy just because you displayed a large table, we have a downsampling mechanism in place.
23+
When an interactive table is displayed by `itables`, the table data is embedded into the notebook itself. Large tables need to be downsampled, otherwise your notebook will become huge and irresponsive.
2424

25-
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`, and display a warning that points to the `itables` documentation.
25+
Downsampling occurs when the table data is larger than `maxBytes`, which is equal to 64KB by default. When downsampling occurs, a warning is displayed below the table, which points to the `itables` documentation.
2626

27-
If you wish, you can increase the value of `maxBytes` or even deactivate the limit (with `maxBytes=0`). Similarly, you can set a limit on the number of rows (`maxRows`, defaults to 0) or columns (`maxColumns`, defaults to `200`).
27+
If you wish, you can increase the value of `maxBytes` or even deactivate the limit (with `maxBytes=0`) - but again, that will break your notebook when you display a large dataframe.
28+
29+
Similarly, you can set a limit on the number of rows (`maxRows`, defaults to 0) or columns (`maxColumns`, defaults to `200`).
2830

2931
```{code-cell} ipython3
3032
import itables
@@ -33,10 +35,11 @@ itables.init_notebook_mode()
3335
```
3436

3537
```{code-cell} ipython3
36-
itables.options.lengthMenu = [2, 5, 10, 20, 50, 100, 200, 500]
38+
:tags: [full-width]
39+
3740
itables.options.maxBytes = "8KB"
3841
39-
df = itables.sample_dfs.get_indicators()
42+
df = itables.sample_dfs.get_countries(html=False)
4043
itables.downsample.as_nbytes(itables.options.maxBytes), itables.downsample.nbytes(df)
4144
```
4245

@@ -51,7 +54,7 @@ To show the table in full, we can modify the value of `maxBytes` either locally:
5154
```{code-cell} ipython3
5255
:tags: [full-width]
5356
54-
itables.show(df, maxBytes=0)
57+
itables.show(df, maxBytes=32768)
5558
```
5659

5760
or globally:

docs/options/buttons.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ The DataTables [buttons](https://datatables.net/extensions/buttons/) let you cop
1919
To display the buttons, you need to pass a `buttons` argument to the `show` function:
2020

2121
```{code-cell} ipython3
22+
:tags: [full-width]
23+
2224
import itables
2325
2426
itables.init_notebook_mode()

docs/py/apps/notebook.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
# name: itables
1515
# ---
1616

17+
# %% tags=["remove-cell"]
18+
# pyright: reportUnusedExpression=false
19+
1720
# %% [markdown]
1821
# # Notebook Mode
1922
#
@@ -26,7 +29,12 @@
2629

2730
# %% [markdown]
2831
# You can go back to the standard HTML representation of Pandas DataFrames with `init_notebook_mode(all_interactive=False)`.
29-
#
32+
33+
# %% tags=["full-width"]
34+
df = itables.sample_dfs.get_countries(html=False)
35+
df
36+
37+
# %% [markdown]
3038
# Note that the `init_connected_mode` function also activates ITable's offline mode, unless you call it with a `connected=False` argument.
3139
#
3240
#
@@ -44,16 +52,5 @@
4452
#
4553
# If you prefer to render only certain tables using `itables`, or want to set additional options, use `show`:
4654

47-
# %%
48-
df = itables.sample_dfs.get_countries(html=False)
49-
50-
itables.show(
51-
df,
52-
caption="A DataFrame rendered with ITables",
53-
lengthMenu=[2, 5, 10, 25, 50, 100, 250],
54-
)
55-
56-
# %% [markdown]
57-
# ## HTML
58-
#
59-
# The `show` function simply displays the HTML snippet for the table, which is obtained with `to_html_datatable`. See more in the section on [HTML export](html.md).
55+
# %% tags=["full-width"]
56+
itables.show(df, caption="A DataFrame rendered with ITables")

docs/py/downsampling.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,23 @@
2020
# %% [markdown]
2121
# # Downsampling
2222
#
23-
# When an interactive table is displayed by `itables`, the table data is embedded in the notebook output. As we don't want your notebook to become super heavy just because you displayed a large table, we have a downsampling mechanism in place.
23+
# When an interactive table is displayed by `itables`, the table data is embedded into the notebook itself. Large tables need to be downsampled, otherwise your notebook will become huge and irresponsive.
2424
#
25-
# 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`, and display a warning that points to the `itables` documentation.
25+
# Downsampling occurs when the table data is larger than `maxBytes`, which is equal to 64KB by default. When downsampling occurs, a warning is displayed below the table, which points to the `itables` documentation.
2626
#
27-
# If you wish, you can increase the value of `maxBytes` or even deactivate the limit (with `maxBytes=0`). Similarly, you can set a limit on the number of rows (`maxRows`, defaults to 0) or columns (`maxColumns`, defaults to `200`).
27+
# If you wish, you can increase the value of `maxBytes` or even deactivate the limit (with `maxBytes=0`) - but again, that will break your notebook when you display a large dataframe.
28+
#
29+
# Similarly, you can set a limit on the number of rows (`maxRows`, defaults to 0) or columns (`maxColumns`, defaults to `200`).
2830

2931
# %%
3032
import itables
3133

3234
itables.init_notebook_mode()
3335

34-
# %%
35-
itables.options.lengthMenu = [2, 5, 10, 20, 50, 100, 200, 500]
36+
# %% tags=["full-width"]
3637
itables.options.maxBytes = "8KB"
3738

38-
df = itables.sample_dfs.get_indicators()
39+
df = itables.sample_dfs.get_countries(html=False)
3940
itables.downsample.as_nbytes(itables.options.maxBytes), itables.downsample.nbytes(df)
4041

4142
# %% tags=["full-width"]
@@ -45,7 +46,7 @@
4546
# To show the table in full, we can modify the value of `maxBytes` either locally:
4647

4748
# %% tags=["full-width"]
48-
itables.show(df, maxBytes=0)
49+
itables.show(df, maxBytes=32768)
4950

5051
# %% [markdown]
5152
# or globally:

docs/py/options/buttons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#
2222
# To display the buttons, you need to pass a `buttons` argument to the `show` function:
2323

24-
# %%
24+
# %% tags=["full-width"]
2525
import itables
2626

2727
itables.init_notebook_mode()

docs/py/quick_start.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
#
6262
# ## Activate ITables
6363
#
64-
# Activate the interactive mode in notebook-like environment with `init_notebook_mode`:
64+
# Activate the interactive mode in notebook-like environment with [`init_notebook_mode`](apps/notebook.md):
6565

6666
# %%
6767
import itables
@@ -73,7 +73,7 @@
7373
# is displayed as an interactive [DataTables](https://datatables.net/),
7474
# which lets you explore, filter or sort your data.
7575

76-
# %%
76+
# %% tags=["full-width"]
7777
df = itables.sample_dfs.get_countries(html=False)
7878
df
7979

docs/quick_start.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ conda install itables -c conda-forge
6161

6262
## Activate ITables
6363

64-
Activate the interactive mode in notebook-like environment with `init_notebook_mode`:
64+
Activate the interactive mode in notebook-like environment with [`init_notebook_mode`](apps/notebook.md):
6565

6666
```{code-cell} ipython3
6767
import itables
@@ -74,6 +74,8 @@ is displayed as an interactive [DataTables](https://datatables.net/),
7474
which lets you explore, filter or sort your data.
7575

7676
```{code-cell} ipython3
77+
:tags: [full-width]
78+
7779
df = itables.sample_dfs.get_countries(html=False)
7880
df
7981
```

0 commit comments

Comments
 (0)