---
jupytext:
  formats: docs///md:myst,docs/py///py:percent
  notebook_metadata_filter: -jupytext.text_representation.jupytext_version
  text_representation:
    extension: .md
    format_name: myst
    format_version: 0.13
kernelspec:
  display_name: python3
  language: python
  name: python3
---

```{code-cell} ipython3
:tags: [remove-cell]

# pyright: reportUnusedExpression=false
```

# Downsampling

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 unresponsive.

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.

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.

Similarly, you can set a limit on the number of rows (`maxRows`, defaults to 0) or columns (`maxColumns`, defaults to `200`).

```{code-cell} ipython3
import itables

itables.init_notebook_mode()
```

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

itables.options.maxBytes = "8KB"

df = itables.sample_dfs.get_countries()
itables.downsample.as_nbytes(itables.options.maxBytes), itables.downsample.nbytes(df)
```

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

df
```

To show the table in full, we can modify the value of `maxBytes` either locally:

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

itables.show(df, maxBytes=32768)
```

or globally:

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

itables.options.maxBytes = "1MB"
df
```
