# dask.dataframe.DataFrame.to_html

#### DataFrame.to_html(max_rows=5)

Render a DataFrame as an HTML table.

This docstring was copied from pandas.DataFrame.to_html.

Some inconsistencies with the Dask version may exist.

Converts the DataFrame into an HTML `<table>` element. The resulting
HTML can be written to a file or returned as a string. This is useful
for embedding tabular data in web pages or HTML-based reports.

* **Parameters:**
  **buf**
  : Buffer to write to. If None, the output is returned as a string.

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

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

  **header**
  : Whether to print column labels, default True.

  **index**
  : Whether to print index (row) labels.

  **na_rep**
  : String representation of `NaN` to use.

  **formatters**
  : 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**
  : 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`.

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

  **index_names**
  : Prints the names of the indexes.

  **justify**
  : 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**
  : Maximum number of rows to display in the console.

  **max_cols**
  : Maximum number of columns to display in the console.

  **show_dimensions**
  : Display DataFrame dimensions (number of rows by number of columns).

  **decimal**
  : Character recognized as decimal separator, e.g. ‘,’ in Europe.

  **bold_rows**
  : Make the row labels bold in the output.

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

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

  **notebook**
  : Whether the generated HTML is for IPython Notebook.

  **border**
  : When an integer value is provided, it sets the border attribute in
    the opening tag, specifying the thickness of the border.
    If `False` or `0` is passed, the border attribute will not
    be present in the `<table>` tag.
    The default value for this parameter is governed by
    `pd.options.display.html.border`.

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

  **render_links**
  : Convert URLs to HTML links.

  **encoding**
  : Set character encoding.
* **Returns:**
  str or None
  : If buf is None, returns the result as a string. Otherwise returns
    None.

#### SEE ALSO
[`to_string`](dask.dataframe.DataFrame.to_string.html.md#dask.dataframe.DataFrame.to_string)
: Convert DataFrame to a string.

### Examples

```pycon
>>> df = pd.DataFrame(data={"col1": [1, 2], "col2": [4, 3]})
>>> html_string = df.to_html()
>>> print(html_string)
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>col1</th>
      <th>col2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>1</td>
      <td>4</td>
    </tr>
    <tr>
      <th>1</th>
      <td>2</td>
      <td>3</td>
    </tr>
  </tbody>
</table>
```

HTML output

|    |   col1 |   col2 |
|----|--------|--------|
|  0 |      1 |      4 |
|  1 |      2 |      3 |
```pycon
>>> df = pd.DataFrame(data={"col1": [1, 2], "col2": [4, 3]})
>>> html_string = df.to_html(index=False)
>>> print(html_string)
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th>col1</th>
      <th>col2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>4</td>
    </tr>
    <tr>
      <td>2</td>
      <td>3</td>
    </tr>
  </tbody>
</table>
```

HTML output

|   col1 |   col2 |
|--------|--------|
|      1 |      4 |
|      2 |      3 |
<!-- !! processed by numpydoc !! -->
