样式#

Styler 对象由 pandas.DataFrame.style 返回。

Styler 构造函数#

Styler (data[, precision, table_styles, ...])

使用 HTML 和 CSS 根据数据帮助样式化 DataFrame 或 Series。

Styler.from_custom_template (searchpath[, ...])

用于创建 Styler 子类的工厂函数。

Styler 属性#

样式应用#

Styler.apply (func[, axis, subset])

按列、按行或按表应用 CSS 样式函数。

Styler.map (func[, subset])

逐元素应用 CSS 样式函数。

Styler.apply_index (func[, axis, level])

按级别将 CSS 样式函数应用于索引或列标题。

Styler.map_index (func[, axis, level])

逐元素应用 CSS 样式函数到索引或列标题。

Styler.format ([formatter, subset, na_rep, ...])

设置单元格的文本显示值格式。

Styler.format_index ([formatter, axis, ...])

设置索引标签或列标题的文本显示值格式。

Styler.relabel_index (labels[, axis, level])

重命名索引或列标题的键,以显示一组指定的值。

Styler.hide ([subset, axis, level, names])

隐藏整个索引/列标题,或从显示中隐藏特定行/列。

Styler.concat (other)

附加另一个 Styler 以将输出合并为单个表格。

Styler.set_td_classes (classes)

设置 <td> HTML 元素的 class 属性。

Styler.set_table_styles ([table_styles, ...])

设置包含在 <style> HTML 元素中的表格样式。

Styler.set_table_attributes (attributes)

设置添加到 <table> HTML 元素的表格属性。

Styler.set_tooltips (ttips[, props, css_class])

设置 Styler 上的字符串 DataFrame,生成 :hover 工具提示。

Styler.set_caption (caption)

设置添加到 <caption> HTML 元素的文本。

Styler.set_sticky ([axis, pixel_size, levels])

添加 CSS 使索引或列标题在滚动框架中永久显示。

Styler.set_properties ([subset])

为给定子集设置定义的 CSS 属性到每个 <td> HTML 元素。

Styler.set_uuid (uuid)

设置应用于 HTML 元素 id 属性的 uuid。

Styler.clear ()

重置 Styler,移除先前应用的所有样式。

Styler.pipe (func, *args, **kwargs)

应用 func(self, *args, **kwargs),并返回结果。

内置样式#

Styler.highlight_null ([color, subset, props])

使用样式高亮显示缺失值。

Styler.highlight_max ([subset, color, axis, ...])

使用样式高亮显示最大值。

Styler.highlight_min ([subset, color, axis, ...])

使用样式高亮显示最小值。

Styler.highlight_between ([subset, color, ...])

使用样式高亮显示定义的范围。

Styler.highlight_quantile ([subset, color, ...])

使用样式高亮显示由分位数定义的值。

Styler.background_gradient ([cmap, low, ...])

在背景中应用渐变样式。

Styler.text_gradient ([cmap, low, high, ...])

用渐变样式为文本着色。

Styler.bar ([subset, axis, color, cmap, ...])

在单元格背景中绘制条形图。

样式导出和导入#

Styler.to_html ([buf, table_uuid, ...])

将 Styler 以 HTML-CSS 格式写入文件、缓冲区或字符串。

Styler.to_latex ([buf, column_format, ...])

将 Styler 以 LaTeX 格式写入文件、缓冲区或字符串。

Styler.to_excel (excel_writer[, sheet_name, ...])

将 Styler 写入 Excel 工作表。

Styler.to_string ([buf, encoding, ...])

将 Styler 以文本格式写入文件、缓冲区或字符串。

Styler.export ()

导出应用于当前 Styler 的样式。

Styler.use (styles)

为当前的 Styler 设置样式。