Skip to content

Commit 9ef7916

Browse files
committed
Rewrite parts of quick_start.md
1 parent 1dc1872 commit 9ef7916

File tree

1 file changed

+46
-40
lines changed

1 file changed

+46
-40
lines changed

docs/quick_start.md

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ that you can sort, paginate, scroll or filter.
3333
ITables is just about how tables are displayed. You can turn it on and off in just two lines,
3434
with no other impact on your data workflow.
3535

36-
The `itables` package only depends on `numpy`, `pandas` and `IPython`
36+
The `itables` package depends only on `numpy`, `pandas` and `IPython`
3737
which you must already have if you work with Pandas in Jupyter (add `polars`, `pyarrow` if you
3838
work with Polars DataFrames).
3939

40-
## Quick start
40+
## Installation
4141

4242
Install the `itables` package with either
4343

@@ -50,6 +50,8 @@ or
5050
conda install itables -c conda-forge
5151
```
5252

53+
## Activate ITables
54+
5355
Activate the interactive mode for all series and dataframes with
5456

5557
```{code-cell}
@@ -62,60 +64,64 @@ After this, any Pandas or Polars DataFrame, or Series,
6264
is displayed as an interactive [datatables.net](https://datatables.net/) table,
6365
which lets you explore, filter or sort your data.
6466

65-
HTML content is supported, which means that you can have formatted text,
66-
links or even images in your tables:
67-
6867
```{code-cell}
69-
:tags: [full-width]
70-
7168
from itables.sample_dfs import get_countries
7269
73-
df = get_countries()
70+
df = get_countries(html=False)
7471
df
7572
```
7673

77-
If you prefer to render just one series or dataframe as an interactive table, use `show`:
74+
## Offline mode versus connected mode
7875

79-
```{code-cell}
80-
from itables import show
81-
from itables.sample_dfs import get_population
76+
ITables use two Javascript libraries:
77+
[jquery](https://jquery.com/) and [datatables.net](https://datatables.net/).
8278

83-
x = get_population()
84-
show(x)
85-
```
79+
By default `itables` works offline. No internet connection is required
80+
as the two libraries are embedded into the notebook itself
81+
when you execute `init_notebook_mode`.
82+
83+
In some contexts (Jupyter Book, Jupyter Colab, etc...) you might
84+
prefer to load the libraries dynamically from the internet.
85+
To do so, add the argument `connected=True` when you
86+
execute `init_notebook_mode`. This will also make your notebook lighter by
87+
about [700kB](https://github.com/mwouts/itables/blob/main/tests/test_connected_notebook_is_small.py).
8688

87-
The default rendering should make sense in most cases. You can also
88-
have a look at the [advanced parameters](advanced_parameters.md)
89-
if you wish to pass specific arguments to the underlying
90-
[datatables.net](https://datatables.net/) library:
89+
## Formatting specific tables only
90+
91+
If you prefer to render only certain series or dataframes using `itables`,
92+
or you want to use the [advanced parameters](advanced_parameters.md), then
93+
use `init_notebook_mode(all_interactive=False)` then `show`:
9194

9295
```{code-cell}
93-
from itables import JavascriptCode
94-
95-
x = get_population()
96-
show(
97-
x,
98-
columnDefs=[
99-
{
100-
"targets": "_all",
101-
"render": JavascriptCode("$.fn.dataTable.render.number(',')"),
102-
}
103-
],
104-
)
105-
```
96+
from itables import show
10697
107-
## Offline mode
98+
show(df, lengthMenu=[2, 5, 10, 25, 50, 100, 250])
99+
```
108100

109-
Since `itables==1.0.0`, the [jquery](https://jquery.com/) and [datatables.net](https://datatables.net/) libraries and CSS
110-
are injected in the notebook when you execute `init_notebook_mode` with its default argument `connected=False`.
111-
Thanks to this the interactive tables will work even without a connection to the internet.
101+
## HTML content
112102

113-
If you prefer to load the libraries dynamically (and keep the notebook lighter), use `connected=True` when you
114-
execute `init_notebook_mode`.
103+
HTML content is supported, which means that you can have formatted text,
104+
links or even images in your tables:
115105

116-
## Advanced parameters
106+
```{code-cell}
107+
:tags: [full-width]
117108
118-
The `show` method let you pass parameters to [datatables.net](https://datatables.net/)'s `DataTable()`'s constructor - see the [advanced parameters examples](advanced_parameters.md).
109+
df["flag"] = [
110+
'<a href="https://flagpedia.net/{code}">'
111+
'<img src="https://flagpedia.net/data/flags/h80/{code}.webp" '
112+
'alt="Flag of {country}"></a>'.format(code=code.lower(), country=country)
113+
for code, country in zip(df.index, df["country"])
114+
]
115+
df["country"] = [
116+
'<a href="https://en.wikipedia.org/wiki/{}">{}</a>'.format(country, country)
117+
for country in df["country"]
118+
]
119+
df["capital"] = [
120+
'<a href="https://en.wikipedia.org/wiki/{}">{}</a>'.format(capital, capital)
121+
for capital in df["capital"]
122+
]
123+
df
124+
```
119125

120126
## Try ITables on Binder
121127

0 commit comments

Comments
 (0)