pandas.io.formats.style.Styler.to_html

Styler.to_html(buf=None, *, table_uuid=None, table_attributes=None, encoding=None, doctype_html=False, exclude_styles=False)[source]

Write Styler to a file, buffer or string in HTML-CSS format.

New in version 1.3.0.

Parameters
bufstr, Path, or StringIO-like, optional, default None

Buffer to write to. If None, the output is returned as a string.

table_uuidstr, optional

Id attribute assigned to the <table> HTML element in the format:

<table id="T_<table_uuid>" ..>

If not given uses Styler’s initially assigned value.

table_attributesstr, optional

Attributes to assign within the <table> HTML element in the format:

<table .. <table_attributes> >

If not given defaults to Styler’s preexisting value.

encodingstr, optional

Character encoding setting for file output, and HTML meta tags, defaults to “utf-8” if None.

doctype_htmlbool, default False

Whether to output a fully structured HTML file including all HTML elements, or just the core <style> and <table> elements.

exclude_stylesbool, default False

Whether to include the <style> element and all associated element class and id identifiers, or solely the <table> element without styling identifiers.

Returns
str or None

If buf is None, returns the result as a string. Otherwise returns None.

See also

DataFrame.to_html

Write a DataFrame to a file, buffer or string in HTML format.