Classes

Classes#

Select how your table looks like with the classes argument of the show function, or by changing itables.options.classes.

The default value for classes is "display nowrap compact" ("compact" was added in ITables v2.7).

Remove "compact" if you want a less dense table:

import pandas as pd

import itables

itables.init_notebook_mode()

df = itables.sample_dfs.get_countries()

itables.show(df, classes="display nowrap")
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)

Remove "nowrap" if you want the cell content to be wrapped:

itables.show(
    pd.DataFrame({"text": ["This is a " + "very " * 60 + "long text"]}),
    classes="display compact",
)
text
This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text

More options like "cell-border" are available:

itables.show(df, classes="display nowrap compact cell-border")
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

You can change the default for all your notebooks and apps by creating an itables.toml configuration file in the current or a parent directory, with e.g. this content:

classes = ["display", "nowrap"]