pandas.io.formats.style.Styler.set_uuid#

Styler.set_uuid(uuid)[source]#

Set the uuid applied to id attributes of HTML elements.

Useful for controlling the HTML id attributes when embedding multiple styled DataFrames in the same HTML page, ensuring there are no CSS conflicts between them.

Parameters:
uuidstr

The uuid to be applied to id attributes of HTML elements.

Returns:
Styler

Instance of class with specified uuid for id attributes set.

See also

Styler.set_caption

Set the text added to a <caption> HTML element.

Styler.set_td_classes

Set the class attribute of <td> HTML elements.

Styler.set_tooltips

Set the DataFrame of strings on Styler generating :hover tooltips.

Notes

Almost all HTML elements within the table, and including the <table> element are assigned id attributes. The format is T_uuid_<extra> where <extra> is typically a more specific identifier, such as row1_col2.

Examples

>>> df = pd.DataFrame([[1, 2], [3, 4]], index=["A", "B"], columns=["c1", "c2"])

You can get the id attributes with the following:

>>> print((df).style.to_html())

To add a title to column c1, its id is T_20a7d_level0_col0:

>>> df.style.set_uuid("T_20a7d_level0_col0").set_caption("Test")
...

Please see: Table visualization for more examples.