Select

Select#

The select extension let you select rows (or cells).

The selected_rows attribute

It is possible to access the selected_rows back in Python but for this you will have to use, instead of show, either

⚠ When a table has been downsampled, only the visible rows can be selected.

Tip

The select option also interacts with the buttons extension. If you click on the CSV or Excel export while having selected some rows, only those rows will be exported - see the example below.

import itables

itables.init_notebook_mode()

itables.show(
    itables.sample_dfs.get_countries(),
    select=True,
    selected_rows=[2, 4, 5],
    buttons=["copyHtml5", "csvHtml5", "excelHtml5"],
)
region country capital longitude latitude
code
AWLatin America & Caribbean ArubaOranjestad-70.01670012.516700
AFSouth AsiaAfghanistanKabul69.17610034.522800
AOSub-Saharan Africa AngolaLuanda13.242000-8.811550
ALEurope & Central AsiaAlbaniaTirane19.81720041.331700
ADEurope & Central AsiaAndorraAndorra la Vella1.52180042.507500
AEMiddle East & North AfricaUnited Arab EmiratesAbu Dhabi54.37050024.476400
ARLatin America & Caribbean ArgentinaBuenos Aires-58.417300-34.611800
AMEurope & Central AsiaArmeniaYerevan44.50900040.159600
ASEast Asia & PacificAmerican SamoaPago Pago-170.691000-14.284600
AGLatin America & Caribbean Antigua and BarbudaSaint John's-61.84560017.117500
(198 more rows not shown)

Tip

The select option accept multiple values, as documented here:

  • select=True or select="os" let you select using single click, shift-click and ctrl-click

  • select="single" let you select a single row

  • select="multi" for single click selection of multiple rows, select="multi+shift", …

With select={"style": "os", "items": "cell"} you can let the user select specific cells, however the cell selection is not exposed in Python, nor taken into account when exporting the data.