pandas 1.4.2

ParametersReturnsBackRef
to_html(self, buf: 'FilePath | WriteBuffer[str] | None' = None, columns: 'Sequence[str] | None' = None, col_space: 'ColspaceArgType | None' = None, header: 'bool | Sequence[str]' = True, index: 'bool' = True, na_rep: 'str' = 'NaN', formatters: 'FormattersType | None' = None, float_format: 'FloatFormatType | None' = None, sparsify: 'bool | None' = None, index_names: 'bool' = True, justify: 'str | None' = None, max_rows: 'int | None' = None, max_cols: 'int | None' = None, show_dimensions: 'bool | str' = False, decimal: 'str' = '.', bold_rows: 'bool' = True, classes: 'str | list | tuple | None' = None, escape: 'bool' = True, notebook: 'bool' = False, border: 'int | None' = None, table_id: 'str | None' = None, render_links: 'bool' = False, encoding: 'str | None' = None)

Parameters

buf : str, Path or StringIO-like, optional, default None

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

columns : sequence, optional, default None

The subset of columns to write. Writes all columns by default.

col_space : str or int, list or dict of int or str, optional

The minimum width of each column in CSS length units. An int is assumed to be px units.

versionadded

Ability to use str.

header : bool, optional

Whether to print column labels, default True.

index : bool, optional, default True

Whether to print index (row) labels.

na_rep : str, optional, default 'NaN'

String representation of NaN to use.

formatters : list, tuple or dict of one-param. functions, optional

Formatter functions to apply to columns' elements by position or name. The result of each function must be a unicode string. List/tuple must be of length equal to the number of columns.

float_format : one-parameter function, optional, default None

Formatter function to apply to columns' elements if they are floats. This function must return a unicode string and will be applied only to the non- NaN elements, with NaN being handled by na_rep .

versionchanged
sparsify : bool, optional, default True

Set to False for a DataFrame with a hierarchical index to print every multiindex key at each row.

index_names : bool, optional, default True

Prints the names of the indexes.

justify : str, default None

How to justify the column labels. If None uses the option from the print configuration (controlled by set_option), 'right' out of the box. Valid values are

  • left

  • right

  • center

  • justify

  • justify-all

  • start

  • end

  • inherit

  • match-parent

  • initial

  • unset.

max_rows : int, optional

Maximum number of rows to display in the console.

max_cols : int, optional

Maximum number of columns to display in the console.

show_dimensions : bool, default False

Display DataFrame dimensions (number of rows by number of columns).

decimal : str, default '.'

Character recognized as decimal separator, e.g. ',' in Europe.

bold_rows : bool, default True

Make the row labels bold in the output.

classes : str or list or tuple, default None

CSS class(es) to apply to the resulting html table.

escape : bool, default True

Convert the characters <, >, and & to HTML-safe sequences.

notebook : {True, False}, default False

Whether the generated HTML is for IPython Notebook.

border : int

A border=border attribute is included in the opening :None:None:`<table>` tag. Default pd.options.display.html.border .

table_id : str, optional

A css id is included in the opening :None:None:`<table>` tag if specified.

render_links : bool, default False

Convert URLs to HTML links.

encoding : str, default "utf-8"

Set character encoding.

versionadded

Returns

str or None

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

Render a DataFrame as an HTML table.

See Also

to_string

Convert DataFrame to a string.

Examples

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

pandas.core.generic.NDFrame.to_latex pandas.core.frame.DataFrame.to_xml pandas.core.frame.DataFrame.to_string

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/frame.py#2846
type: <class 'function'>
Commit: