Skip to content

pandasx / Styler

Class: Styler ​

Defined in: src/style.ts:58

Constructors ​

Constructor ​

new Styler(data): Styler

Defined in: src/style.ts:74

Parameters ​

ParameterType
dataDataFrame

Returns ​

Styler

Properties ​

PropertyModifierTypeDefined in
datareadonlyDataFramesrc/style.ts:59

Methods ​

apply() ​

apply(fn, options?): this

Defined in: src/style.ts:124

Column-wise (axis 0, default), row-wise (axis 1) or table-wise (axis null): fn gets a Series (or the sub-frame) and returns CSS per element.

Parameters ​

ParameterType
fn(data) => DataFrame | Series | readonly (string | null | undefined)[] | (string | null | undefined)[][]
options{ axis?: StyleAxis; subset?: Subset; }
options.axis?StyleAxis
options.subset?Subset

Returns ​

this


applymap() ​

applymap(fn, options?): this

Defined in: src/style.ts:116

Parameters ​

ParameterType
fn(value) => string | null | undefined
options{ subset?: Subset; }
options.subset?Subset

Returns ​

this


backgroundGradient() ​

backgroundGradient(options?): this

Defined in: src/style.ts:254

Background colour by value (numeric columns), with readable text colour.

Parameters ​

ParameterType
options{ axis?: StyleAxis; cmap?: string; high?: number; low?: number; subset?: Subset; textColorThreshold?: number; vmax?: number; vmin?: number; }
options.axis?StyleAxis
options.cmap?string
options.high?number
options.low?number
options.subset?Subset
options.textColorThreshold?number
options.vmax?number
options.vmin?number

Returns ​

this


bar() ​

bar(options?): this

Defined in: src/style.ts:291

In-cell bar charts via CSS gradients. align: 'left' (default), 'zero' or 'mid'.

Parameters ​

ParameterType
options{ align?: "left" | "zero" | "mid"; axis?: StyleAxis; color?: string | [string, string]; subset?: Subset; vmax?: number; vmin?: number; width?: number; }
options.align?"left" | "zero" | "mid"
options.axis?StyleAxis
options.color?string | [string, string]
options.subset?Subset
options.vmax?number
options.vmin?number
options.width?number

Returns ​

this


cellStyle() ​

cellStyle(i, j): string[]

Defined in: src/style.ts:355

The CSS declarations attached to cell (row i, column j).

Parameters ​

ParameterType
inumber
jnumber

Returns ​

string[]


format() ​

format(formatter?, options?): this

Defined in: src/style.ts:158

Display format: a Python template ('{:,.2f}', 'R$ {:.2f}', '{:.1%}'), a function, or {column: template | function}.

Parameters ​

ParameterType
formatter?Formatter | Record<string, Formatter> | null
options?{ decimal?: string; naRep?: string; precision?: number; subset?: Subset; thousands?: string; }
options.decimal?string
options.naRep?string
options.precision?number
options.subset?Subset
options.thousands?string

Returns ​

this


formatIndex() ​

formatIndex(formatter): this

Defined in: src/style.ts:177

Formats the index labels.

Parameters ​

ParameterType
formatterFormatter

Returns ​

this


hide() ​

hide(options?): this

Defined in: src/style.ts:341

Hides the index / header (no subset) or some rows / columns.

Parameters ​

ParameterType
options{ axis?: 0 | 1 | "columns" | "index"; subset?: readonly string[] | readonly Label[]; }
options.axis?0 | 1 | "columns" | "index"
options.subset?readonly string[] | readonly Label[]

Returns ​

this


highlightBetween() ​

highlightBetween(options?): this

Defined in: src/style.ts:223

Parameters ​

ParameterType
options{ color?: string; inclusive?: "both" | "neither" | "left" | "right"; left?: number; props?: string; right?: number; subset?: Subset; }
options.color?string
options.inclusive?"both" | "neither" | "left" | "right"
options.left?number
options.props?string
options.right?number
options.subset?Subset

Returns ​

this


highlightMax() ​

highlightMax(options?): this

Defined in: src/style.ts:215

Parameters ​

ParameterType
options{ axis?: StyleAxis; color?: string; props?: string; subset?: Subset; }
options.axis?StyleAxis
options.color?string
options.props?string
options.subset?Subset

Returns ​

this


highlightMin() ​

highlightMin(options?): this

Defined in: src/style.ts:216

Parameters ​

ParameterType
options{ axis?: StyleAxis; color?: string; props?: string; subset?: Subset; }
options.axis?StyleAxis
options.color?string
options.props?string
options.subset?Subset

Returns ​

this


highlightNull() ​

highlightNull(options?): this

Defined in: src/style.ts:218

Parameters ​

ParameterType
options{ color?: string; props?: string; subset?: Subset; }
options.color?string
options.props?string
options.subset?Subset

Returns ​

this


highlightQuantile() ​

highlightQuantile(options?): this

Defined in: src/style.ts:235

Parameters ​

ParameterType
options{ axis?: StyleAxis; color?: string; props?: string; qLeft?: number; qRight?: number; subset?: Subset; }
options.axis?StyleAxis
options.color?string
options.props?string
options.qLeft?number
options.qRight?number
options.subset?Subset

Returns ​

this


map() ​

map(fn, options?): this

Defined in: src/style.ts:110

Element-wise: fn(value) returns CSS ('color: red;') or null.

Parameters ​

ParameterType
fn(value) => string | null | undefined
options{ subset?: Subset; }
options.subset?Subset

Returns ​

this


render() ​

render(): string

Defined in: src/style.ts:426

Same as toHtml().

Returns ​

string


setCaption() ​

setCaption(caption): this

Defined in: src/style.ts:326

Parameters ​

ParameterType
captionstring

Returns ​

this


setNaRep() ​

setNaRep(naRep): this

Defined in: src/style.ts:337

Parameters ​

ParameterType
naRepstring

Returns ​

this


setPrecision() ​

setPrecision(precision): this

Defined in: src/style.ts:338

Parameters ​

ParameterType
precisionnumber

Returns ​

this


setProperties() ​

setProperties(props, options?): this

Defined in: src/style.ts:147

The same CSS on every cell of subset.

Parameters ​

ParameterType
propsstring | Record<string, string>
options{ subset?: Subset; }
options.subset?Subset

Returns ​

this


setTableAttributes() ​

setTableAttributes(attributes): this

Defined in: src/style.ts:335

Parameters ​

ParameterType
attributesstring

Returns ​

this


setTableStyles() ​

setTableStyles(styles, options?): this

Defined in: src/style.ts:329

CSS rules for the table, e.g. [{ selector: 'th', props: 'font-weight: bold;' }].

Parameters ​

ParameterType
stylesreadonly object[]
options{ overwrite?: boolean; }
options.overwrite?boolean

Returns ​

this


setUuid() ​

setUuid(uuid): this

Defined in: src/style.ts:336

Parameters ​

ParameterType
uuidstring

Returns ​

this


textGradient() ​

textGradient(options?): this

Defined in: src/style.ts:259

Text colour by value.

Parameters ​

ParameterType
options{ axis?: StyleAxis; cmap?: string; high?: number; low?: number; subset?: Subset; vmax?: number; vmin?: number; }
options.axis?StyleAxis
options.cmap?string
options.high?number
options.low?number
options.subset?Subset
options.vmax?number
options.vmin?number

Returns ​

this


toExcel() ​

toExcel(path?, options?): Promise<Buffer<ArrayBufferLike>>

Defined in: src/style.ts:457

Writes an .xlsx with background / text colours and bold applied (requires exceljs).

Parameters ​

ParameterType
path?string
options?{ index?: boolean; sheetName?: string; }
options.index?boolean
options.sheetName?string

Returns ​

Promise<Buffer<ArrayBufferLike>>


toHtml() ​

toHtml(options?): string

Defined in: src/style.ts:360

HTML (style block + table), like Styler.to_html().

Parameters ​

ParameterType
options{ doctype?: boolean; excludeStyles?: boolean; tableUuid?: string; }
options.doctype?boolean
options.excludeStyles?boolean
options.tableUuid?string

Returns ​

string


toLatex() ​

toLatex(options?): string

Defined in: src/style.ts:443

LaTeX tabular with the display formats, like Styler.to_latex().

Parameters ​

ParameterType
options{ caption?: string; columnFormat?: string; environment?: "table" | null; hrules?: boolean; label?: string; position?: string; }
options.caption?string
options.columnFormat?string
options.environment?"table" | null
options.hrules?boolean
options.label?string
options.position?string

Returns ​

string


toString() ​

toString(options?): string

Defined in: src/style.ts:431

Formatted text table (formats applied, styles ignored).

Parameters ​

ParameterType
options{ delimiter?: string; }
options.delimiter?string

Returns ​

string

Released under the MIT License.