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
-
- buf:str, Path, or StringIO-like, optional, default None
-
Buffer to write to. If
None
, the output is returned as a string. - table_uuid:str, 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_attributes:str, optional
-
Attributes to assign within the <table> HTML element in the format:
<table .. <table_attributes> >
If not given defaults to Styler’s preexisting value.
- encoding:str, optional
-
Character encoding setting for file output, and HTML meta tags, defaults to “utf-8” if None.
- doctype_html:bool, default False
-
Whether to output a fully structured HTML file including all HTML elements, or just the core
<style>
and<table>
elements. - exclude_styles:bool, default False
-
Whether to include the
<style>
element and all associated elementclass
andid
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.
© 2008–2021, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/1.3.4/reference/api/pandas.io.formats.style.Styler.to_html.html