Style#
The show function has a style argument that determines the layout for a particular table.
The default value for style is "table-layout:auto;width:auto;margin:auto;caption-side:bottom".
Without
width:auto, tables with few columns are stretched to fit the container width.Using
margin:automakes non-wide tables centered.
import pandas as pd
import itables
itables.init_notebook_mode()
df_small = pd.DataFrame({"a": [2, 1]})
You can set a specific width or position for a table using with the style argument of the show function:
itables.show(df_small, style="table-layout:auto;width:50%;float:right")
Loading ITables v2.5.2 from the init_notebook_mode cell...
(need help?) |
or you can also change it for all tables by changing itables.options.style:
itables.options.style = "table-layout:auto;width:auto"
Tip
The height of a table is governed by either lengthMenu or by scrollY.
If you are looking for changing the table content appeareance, see the page on CSS, or the page on Pandas Style.