pub struct StyledDataFrame<'a> { /* private fields */ }Expand description
A lightweight analogue of pandas’ Styler, returned by DataFrame::style.
Directive methods (highlight_max, highlight_min, background_gradient,
format, set_caption) consume and return self so they chain like the
pandas builder API. With no directives set, StyledDataFrame::to_html
reproduces DataFrame::to_html byte-for-byte; once any directive is set,
the renderer emits per-cell inline style attributes and an optional
<caption>.
Implementations§
Source§impl<'a> StyledDataFrame<'a>
impl<'a> StyledDataFrame<'a>
pub fn dataframe(&self) -> &'a DataFrame
Sourcepub fn highlight_max(self, color: &str) -> Self
pub fn highlight_max(self, color: &str) -> Self
Highlight the maximum value in each numeric column with color
(pandas Styler.highlight_max(color=...), axis=0). Ties are all
highlighted, matching pandas.
Sourcepub fn highlight_min(self, color: &str) -> Self
pub fn highlight_min(self, color: &str) -> Self
Highlight the minimum value in each numeric column with color
(pandas Styler.highlight_min(color=...), axis=0).
Sourcepub fn background_gradient(self, low: &str, high: &str) -> Self
pub fn background_gradient(self, low: &str, high: &str) -> Self
Shade numeric cells along a two-colour gradient from low (column
minimum) to high (column maximum). Endpoints are #rrggbb hex
strings; unparseable endpoints make the directive a no-op. Approximates
pandas Styler.background_gradient without a matplotlib colormap.
Sourcepub fn format(self, fmt: &str) -> Self
pub fn format(self, fmt: &str) -> Self
Apply a Python-style format string to numeric cells, e.g. "{:.2f}",
"${:,.2f}", or "{:.1%}" (pandas Styler.format(fmt)). Literal text
surrounding the {...} placeholder is preserved. A format string with
no placeholder leaves values unformatted.
Sourcepub fn na_rep(self, placeholder: &str) -> Self
pub fn na_rep(self, placeholder: &str) -> Self
Render missing / NaN cells with placeholder instead of the default
"NaN" (pandas Styler.format(na_rep=...)).
Sourcepub fn set_caption(self, caption: &str) -> Self
pub fn set_caption(self, caption: &str) -> Self
Set the table caption rendered as a <caption> element
(pandas Styler.set_caption).
Sourcepub fn set_properties(self, props: &[(&str, &str)]) -> Self
pub fn set_properties(self, props: &[(&str, &str)]) -> Self
Apply fixed CSS (property, value) pairs to every data cell
(pandas Styler.set_properties(**css)), e.g.
&[("background-color", "black"), ("color", "white")].
Sourcepub fn bar(self, color: &str) -> Self
pub fn bar(self, color: &str) -> Self
Draw an in-cell horizontal bar chart in each numeric cell, with the
filled width proportional to the value within its column’s [min, max]
range (pandas Styler.bar(color=...)). Rendered as a CSS
linear-gradient background.
Sourcepub fn hide_index(self) -> Self
pub fn hide_index(self) -> Self
Omit the index column and its header from the HTML render
(pandas Styler.hide(axis="index"), formerly hide_index()).
Sourcepub fn to_html(&self, include_index: bool) -> String
pub fn to_html(&self, include_index: bool) -> String
Render the styled DataFrame as an HTML table.
With no directives this matches DataFrame::to_html exactly; with
directives it emits inline cell styles and an optional caption.
Sourcepub fn to_string_table(&self, include_index: bool) -> String
pub fn to_string_table(&self, include_index: bool) -> String
Render the styled DataFrame as the plain text table representation.
Styling directives are HTML-only (as in pandas), so this always renders
the plain DataFrame::to_string_table form.
Sourcepub fn to_html_classed(&self, include_index: bool, class_name: &str) -> String
pub fn to_html_classed(&self, include_index: bool, class_name: &str) -> String
Render the HTML table with a single CSS class.
Sourcepub fn to_html_with_classes(
&self,
include_index: bool,
classes: &[&str],
) -> String
pub fn to_html_with_classes( &self, include_index: bool, classes: &[&str], ) -> String
Render the HTML table with caller-provided CSS classes.
Empty class names are ignored. If no classes remain, the existing
dataframe class is preserved.
Trait Implementations§
Source§impl<'a> Clone for StyledDataFrame<'a>
impl<'a> Clone for StyledDataFrame<'a>
Source§fn clone(&self) -> StyledDataFrame<'a>
fn clone(&self) -> StyledDataFrame<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for StyledDataFrame<'a>
impl<'a> Debug for StyledDataFrame<'a>
Source§impl<'a> PartialEq for StyledDataFrame<'a>
impl<'a> PartialEq for StyledDataFrame<'a>
Source§fn eq(&self, other: &StyledDataFrame<'a>) -> bool
fn eq(&self, other: &StyledDataFrame<'a>) -> bool
self and other values to be equal, and is used by ==.