class, precision=None, table_styles=None, uuid=None, caption=None, table_attributes=None, cell_ids=True, na_rep=None, uuid_len=5)[source]

Helps style a DataFrame or Series according to the data with HTML and CSS.

dataSeries or DataFrame

Data to be styled - either a Series or DataFrame.


Precision to round floats to, defaults to pd.options.display.precision.

table_styleslist-like, default None

List of {selector: (attr, value)} dicts; see Notes.

uuidstr, default None

A unique identifier to avoid CSS collisions; generated automatically.

captionstr, default None

Caption to attach to the table.

table_attributesstr, default None

Items that show up in the opening <table> tag in addition to automatic (by default) id.

cell_idsbool, default True

If True, each cell will have an id attribute in their HTML tag. The id takes the form T_<uuid>_row<num_row>_col<num_col> where <uuid> is the unique identifier, <num_row> is the row number and <num_col> is the column number.

na_repstr, optional

Representation for missing values. If na_rep is None, no special formatting is applied.

New in version 1.0.0.

uuid_lenint, default 5

If uuid is not specified, the length of the uuid to randomly generate expressed in hex characters, in range [0, 32].

New in version 1.2.0.

See also

Return a Styler object containing methods for building a styled HTML representation for the DataFrame.


Most styling will be done by passing style functions into Styler.apply or Styler.applymap. Style functions should return values with strings containing CSS 'attr: value' that will be applied to the indicated cells.

If using in the Jupyter notebook, Styler has defined a _repr_html_ to automatically render itself. Otherwise call Styler.render to get the generated HTML.

CSS classes are attached to the generated HTML

  • Index and Column names include index_name and level<k> where k is its level in a MultiIndex

  • Index label cells include

    • row_heading

    • row<n> where n is the numeric position of the row

    • level<k> where k is the level in a MultiIndex

  • Column label cells include * col_heading * col<n> where n is the numeric position of the column * level<k> where k is the level in a MultiIndex

  • Blank cells include blank

  • Data cells include data



(Jinja2 jinja2.Environment)


(Jinja2 Template)


(Jinja2 Loader)


apply(func[, axis, subset])

Apply a function column-wise, row-wise, or table-wise.

applymap(func[, subset])

Apply a function elementwise.

background_gradient([cmap, low, high, axis, …])

Color the background in a gradient style.

bar([subset, axis, color, width, align, …])

Draw bar chart in the cell backgrounds.


Reset the styler, removing any previously applied styles.


Export the styles to applied to the current Styler.

format(formatter[, subset, na_rep])

Format the text display value of cells.

from_custom_template(searchpath, name)

Factory function for creating a subclass of Styler.


Hide columns from rendering.


Hide any indices from rendering.

highlight_max([subset, color, axis])

Highlight the maximum by shading the background.

highlight_min([subset, color, axis])

Highlight the minimum by shading the background.

highlight_null([null_color, subset])

Shade the background null_color for missing values.

pipe(func, *args, **kwargs)

Apply func(self, *args, **kwargs), and return the result.


Render the built up styles to HTML.


Set the caption on a Styler.


Set the missing data representation on a Styler.


Set the precision used to render.


Method to set one or more non-data dependent properties or each cell.


Set the table attributes.

set_table_styles(table_styles[, axis, overwrite])

Set the table styles on a Styler.


Add string based CSS class names to data cells that will appear within the Styler HTML result.


Set the uuid for a Styler.

to_excel(excel_writer[, sheet_name, na_rep, …])

Write Styler to an Excel sheet.


Set the styles on the current Styler.

where(cond, value[, other, subset])

Apply a function elementwise.