formats.style.Styler()

class pandas.formats.style.Styler(data, precision=None, table_styles=None, uuid=None, caption=None, table_attributes=None) [source]

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

New in version 0.17.1.

Warning

This is a new feature and is under active development. We?ll be adding features and possibly making breaking changes in future releases.

Parameters:

data: Series or DataFrame

precision: int

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

table_styles: list-like, default None

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

uuid: str, default None

a unique identifier to avoid CSS collisons; generated automatically

caption: str, default None

caption to attach to the table

Notes

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 genterated 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 * evel<k> where k is the level in a MultiIndex
  • Blank cells include blank
  • Data cells include data

Attributes

template:

Methods

apply(func[, axis, subset]) Apply a function column-wise, row-wise, or table-wase, updating the HTML representation with the result.
applymap(func[, subset]) Apply a function elementwise, updating the HTML representation with the result.
background_gradient([cmap, low, high, axis, ...]) Color the background in a gradient according to the data in each column (optionally row).
bar([subset, axis, color, width]) Color the background color proptional to the values in each column.
clear() ?Reset? the styler, removing any previously applied styles.
export() Export the styles to applied to the current Styler.
format(formatter[, subset]) Format the text display value of cells.
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]) Shade the background null_color for missing values.
render() Render the built up styles to HTML
set_caption(caption) Se the caption on a Styler
set_precision(precision) Set the precision used to render.
set_properties([subset]) Convience method for setting one or more non-data dependent properties or each cell.
set_table_attributes(attributes) Set the table attributes.
set_table_styles(table_styles) Set the table styles on a Styler.
set_uuid(uuid) Set the uuid for a Styler.
use(styles) Set the styles on the current Styler, possibly using styles from Styler.export.
doc_Pandas
2017-01-12 04:48:21
Comments
Leave a Comment

Please login to continue.