Column Visibility

Column Visibility#

The column visibility buttons of DataTables let you select which columns are visible.

import itables

itables.init_notebook_mode()

df = itables.sample_dfs.get_countries(html=False)

itables.show(
    # column visibility works best with a flat header
    df.reset_index(),
    buttons=["columnsToggle"],
)
Loading ITables v2.4.0rc1 from the init_notebook_mode cell... (need help?)

Tip

The column visibility button is available under many forms.

Check-out buttons=["colvis"] for a single button.

Extend the colvis button with the collection layout.

As always, when porting examples from DataTables to ITables, you will have to convert the JavaScript notation (left) to Python (right) as in the below:

buttons: [
    {
        extend: 'colvis',
        collectionLayout: 'fixed columns',
        popoverTitle: 'Column visibility control'
    }
]
buttons = [
    {
        "extend": "colvis",
        "collectionLayout": "fixed columns",
        "popoverTitle": "Column visibility control"
    }
]