Skip to main content

StyledDataFrame

Struct StyledDataFrame 

Source
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>

Source

pub fn dataframe(&self) -> &'a DataFrame

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub fn na_rep(self, placeholder: &str) -> Self

Render missing / NaN cells with placeholder instead of the default "NaN" (pandas Styler.format(na_rep=...)).

Source

pub fn set_caption(self, caption: &str) -> Self

Set the table caption rendered as a <caption> element (pandas Styler.set_caption).

Source

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")].

Source

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.

Source

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()).

Source

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.

Source

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.

Source

pub fn to_html_classed(&self, include_index: bool, class_name: &str) -> String

Render the HTML table with a single CSS class.

Source

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>

Source§

fn clone(&self) -> StyledDataFrame<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for StyledDataFrame<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for StyledDataFrame<'a>

Source§

fn eq(&self, other: &StyledDataFrame<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for StyledDataFrame<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for StyledDataFrame<'a>

§

impl<'a> RefUnwindSafe for StyledDataFrame<'a>

§

impl<'a> Send for StyledDataFrame<'a>

§

impl<'a> Sync for StyledDataFrame<'a>

§

impl<'a> Unpin for StyledDataFrame<'a>

§

impl<'a> UnsafeUnpin for StyledDataFrame<'a>

§

impl<'a> UnwindSafe for StyledDataFrame<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.