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
the
ITableWidgetthe
ITableDash componentthe
interactive_tableStreamlit component
⚠ 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"],
)
Loading ITables v2.9.0 from the init_notebook_mode cell...
(need help?)
|
| ⓘ | region | country | capital | longitude | latitude |
|---|---|---|---|---|---|
| code | |||||
| AW | Latin America & Caribbean | Aruba | Oranjestad | -70.016700 | 12.516700 |
| AF | South Asia | Afghanistan | Kabul | 69.176100 | 34.522800 |
| AO | Sub-Saharan Africa | Angola | Luanda | 13.242000 | -8.811550 |
| AL | Europe & Central Asia | Albania | Tirane | 19.817200 | 41.331700 |
| AD | Europe & Central Asia | Andorra | Andorra la Vella | 1.521800 | 42.507500 |
| AE | Middle East & North Africa | United Arab Emirates | Abu Dhabi | 54.370500 | 24.476400 |
| AR | Latin America & Caribbean | Argentina | Buenos Aires | -58.417300 | -34.611800 |
| AM | Europe & Central Asia | Armenia | Yerevan | 44.509000 | 40.159600 |
| AS | East Asia & Pacific | American Samoa | Pago Pago | -170.691000 | -14.284600 |
| AG | Latin America & Caribbean | Antigua and Barbuda | Saint John's | -61.845600 | 17.117500 |
| (198 more rows not shown) | |||||
Tip
The select option accept multiple values, as documented here:
select=Trueorselect="os"let you select using single click, shift-click and ctrl-clickselect="single"let you select a single rowselect="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.