Markdown Preview#

itables.show() outside of a notebook#

itables.show() normally displays an interactive DataTable. But that requires a notebook (or another IPython-based, HTML-capable frontend) to render the HTML output in. In a plain Python script, or an interactive Python session started with just python (not ipython), there is nowhere to display HTML at all.

In that case, itables.show() falls back to printing a static preview: a Markdown table with just the first rows - 10 by default, or as many as your pageLength/lengthMenu options say. This is the same fallback (see Static preview) that a table gets when it’s viewed somewhere that can’t run JavaScript, except that here it’s printed as Markdown - since there is no HTML output at all to embed it in - rather than shown as a static HTML table.

to_markdown_table#

You can also build that Markdown table yourself, with to_markdown_table:

import itables

df = itables.sample_dfs.get_countries()
print(itables.to_markdown_table(df))
| code | region                     | country              | capital          | longitude   | latitude   |
| ---- | -------------------------- | -------------------- | ---------------- | ----------- | ---------- |
| 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)*

Markdown tables like this one are simple enough for both humans and AI agents to read directly - e.g. from a script’s console output, or from a notebook’s saved JSON when read as a file rather than rendered.