pandas.io.formats.style.
Styler
Helps style a DataFrame or Series according to the data with HTML and CSS.
Data to be styled - either a Series or DataFrame.
Precision to round floats to, defaults to pd.options.display.precision.
List of {selector: (attr, value)} dicts; see Notes.
A unique identifier to avoid CSS collisions; generated automatically.
Caption to attach to the table.
Items that show up in the opening <table> tag in addition to automatic (by default) id.
<table>
If True, each cell will have an id attribute in their HTML tag. The id takes the form T_<uuid>_row<num_row>_col<num_col> where <uuid> is the unique identifier, <num_row> is the row number and <num_col> is the column number.
id
T_<uuid>_row<num_row>_col<num_col>
<uuid>
<num_row>
<num_col>
Representation for missing values. If na_rep is None, no special formatting is applied
na_rep
New in version 1.0.0.
See also
DataFrame.style
Return a Styler object containing methods for building a styled HTML representation for the DataFrame.
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.
Styler.apply
Styler.applymap
'attr: value'
If using in the Jupyter notebook, Styler has defined a _repr_html_ to automatically render itself. Otherwise call Styler.render to get the generated HTML.
_repr_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_name
level<k>
Index label cells include
row_heading
row<n> where n is the numeric position of the row
row<n>
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
col_heading
col<n>
evel<k>
Blank cells include blank
blank
Data cells include data
data
Attributes
env
(Jinja2 jinja2.Environment)
template
(Jinja2 Template)
loader
(Jinja2 Loader)
Methods
apply(self, func[, axis, subset])
apply
Apply a function column-wise, row-wise, or table-wise.
applymap(self, func[, subset])
applymap
Apply a function elementwise.
background_gradient(self[, cmap, low, high, …])
background_gradient
Color the background in a gradient style.
bar(self[, subset, axis, color, width, …])
bar
Draw bar chart in the cell backgrounds.
clear(self)
clear
Reset the styler, removing any previously applied styles.
export(self)
export
Export the styles to applied to the current Styler.
format(self, formatter[, subset])
format
Format the text display value of cells.
from_custom_template(searchpath, name)
from_custom_template
Factory function for creating a subclass of Styler.
hide_columns(self, subset)
hide_columns
Hide columns from rendering.
hide_index(self)
hide_index
Hide any indices from rendering.
highlight_max(self[, subset, color, axis])
highlight_max
Highlight the maximum by shading the background.
highlight_min(self[, subset, color, axis])
highlight_min
Highlight the minimum by shading the background.
highlight_null(self[, null_color])
highlight_null
Shade the background null_color for missing values.
null_color
pipe(self, func, \*args, \*\*kwargs)
pipe
Apply func(self, *args, **kwargs), and return the result.
func(self, *args, **kwargs)
render(self, \*\*kwargs)
render
Render the built up styles to HTML.
set_caption(self, caption)
set_caption
Set the caption on a Styler.
set_na_rep(self, na_rep)
set_na_rep
Set the missing data representation on a Styler.
set_precision(self, precision)
set_precision
Set the precision used to render.
set_properties(self[, subset])
set_properties
Method to set one or more non-data dependent properties or each cell.
set_table_attributes(self, attributes)
set_table_attributes
Set the table attributes.
set_table_styles(self, table_styles)
set_table_styles
Set the table styles on a Styler.
set_uuid(self, uuid)
set_uuid
Set the uuid for a Styler.
to_excel(self, excel_writer[, sheet_name, …])
to_excel
Write Styler to an Excel sheet.
use(self, styles)
use
Set the styles on the current Styler.
where(self, cond, value[, other, subset])
where