pandasx / Styler
Class: Styler
Defined in: src/style.ts:58
Constructors
Constructor
new Styler(
data):Styler
Defined in: src/style.ts:74
Parameters
| Parameter | Type |
|---|---|
data | DataFrame |
Returns
Styler
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
data | readonly | DataFrame | src/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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
i | number |
j | number |
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
formatter | Formatter |
Returns
this
hide()
hide(
options?):this
Defined in: src/style.ts:341
Hides the index / header (no subset) or some rows / columns.
Parameters
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
caption | string |
Returns
this
setNaRep()
setNaRep(
naRep):this
Defined in: src/style.ts:337
Parameters
| Parameter | Type |
|---|---|
naRep | string |
Returns
this
setPrecision()
setPrecision(
precision):this
Defined in: src/style.ts:338
Parameters
| Parameter | Type |
|---|---|
precision | number |
Returns
this
setProperties()
setProperties(
props,options?):this
Defined in: src/style.ts:147
The same CSS on every cell of subset.
Parameters
| Parameter | Type |
|---|---|
props | string | Record<string, string> |
options | { subset?: Subset; } |
options.subset? | Subset |
Returns
this
setTableAttributes()
setTableAttributes(
attributes):this
Defined in: src/style.ts:335
Parameters
| Parameter | Type |
|---|---|
attributes | string |
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
| Parameter | Type |
|---|---|
styles | readonly object[] |
options | { overwrite?: boolean; } |
options.overwrite? | boolean |
Returns
this
setUuid()
setUuid(
uuid):this
Defined in: src/style.ts:336
Parameters
| Parameter | Type |
|---|---|
uuid | string |
Returns
this
textGradient()
textGradient(
options?):this
Defined in: src/style.ts:259
Text colour by value.
Parameters
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
options | { delimiter?: string; } |
options.delimiter? | string |
Returns
string