sdvplot.reactable
reactable-py columns (pip install sdvplot[reactable]), ported from sdvplotR's reactable_sdv_* functions, plus reactablefmtr's cell formatters (data bars, color tiles and scales, pills, icons, merged columns, highlights, bubbles).
| Name | What it is |
|---|---|
| reactable_sdv_args | The Reactable keyword arguments that make a table look like a registry or reactablefmtr theme. |
| reactable_sdv_bubble_grid | A reactable column of circles (or squares) sized and colored by value, by a color column, or by team. |
| reactable_sdv_color_scales | A reactable column whose cell backgrounds are filled on a color scale, by a color column, or in team colors. |
| reactable_sdv_color_tiles | A reactable column of rounded tiles filled on a color scale, by a color column, or in the row's team color. |
| reactable_sdv_cols_label | One reactable column per team-named column of data (a KC column, a BUF column, ...), its header |
| reactable_sdv_data_bars | A reactable column of horizontal bars sized by value, in a scale color, a color column or the team color. |
| reactable_sdv_frame | A Reactable with a title and subtitle above it and a legend and source line under it, in a Google font. |
| reactable_sdv_gauge | A reactable column that draws each cell's number as a half-circle gauge (an inline SVG) with the value inside. |
| reactable_sdv_headshots | A reactable column that shows each cell's player id as the player's headshot. |
| reactable_sdv_highlight | A reactable column whose highest (or lowest, or both) values are bold, in a color, optionally on a highlight. |
| reactable_sdv_icon_assign | A reactable column that repeats an icon, filled up to the value: a rating in stars, a count in dots. |
| reactable_sdv_icon_legend | An icon legend: each icon, in its color, before its label, for reactable_sdv_frame(legend=...). |
| reactable_sdv_icon_sets | A reactable column that puts an icon beside each number, chosen by the value's quantile bucket. |
| reactable_sdv_icon_trend | A reactable column that marks each change with an up arrow, a down arrow or a dash, the value colored to match. |
| reactable_sdv_legend | A color legend: a row of swatches with a label under each, for reactable_sdv_frame(legend=...). |
| reactable_sdv_logos | A reactable column that shows each cell's team as its logo. |
| reactable_sdv_merge_column | A reactable column that shows a second column's value beside or below each value, after an optional mark. |
| reactable_sdv_pill_buttons | A reactable column whose values sit in rounded pills, in a scale color, a color column or the team color. |
| reactable_sdv_sparkbar | A reactable column that draws each cell's list of numbers as a small bar chart (an inline SVG). |
| reactable_sdv_sparkline | A reactable column that draws each cell's list of numbers as a sparkline (an inline SVG). |
| reactable_sdv_team_color_bar | A reactable column whose cells hold a bar in the row's team color, as long as the value's share of the maximum. |
| reactable_sdv_team_color_bg | A reactable column whose cells are filled with the row's team color, mostly transparent. |
| reactable_sdv_theme | One of reactablefmtr's 27 table themes, or any of the 122 surveyed registry themes (sdv_table_themes()). |
| reactable_sdv_theme_team | A table theme in a team's colors: the header filled with the primary color over a rule in the secondary, |
| reactable_sdv_wordmarks | A reactable column that shows each cell's team as its wordmark. |
reactable_sdv_args
reactable_sdv_args(
name: str,
*,
mode: str = 'light',
) -> dict[str, Any]
The Reactable keyword arguments that make a table look like a registry or reactablefmtr theme.
Arguments
| Name | Type | Description |
|---|---|---|
name | str | A reactablefmtr theme or a registry id, as in reactable_sdv_theme. |
mode | str | "light" or "dark", as in reactable_sdv_theme. |
Returns
dict — theme (a reactable.Theme), striped, highlight (always True), bordered (the theme draws column rules) and compact (its cell padding is 4 pixels or less). A reactablefmtr theme returns its own Theme with the other keys at reactable's defaults.
Raises
InputError: (a ValueError) Asreactable_sdv_theme.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_args
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "wins": [12, 10, 9]})
Reactable(df, **reactable_sdv_args("wikipedia"))
Reactable(df, **reactable_sdv_args("datagolf", mode="dark"))
See also
- reactable_sdv_theme: just the
Theme
reactable_sdv_bubble_grid
reactable_sdv_bubble_grid(
data: Any,
*,
shape: Literal['circles', 'squares'] = 'circles',
colors: collections.abc.Sequence[str] = ('#15607A', '#FFFFFF', '#FA8C00'),
color_ref: str | None = None,
team_col: str | None = None,
league: str | None = None,
which: Literal['primary', 'secondary'] = 'primary',
color_by: str | None = None,
min_value: float | None = None,
max_value: float | None = None,
opacity: float = 1,
bias: float = 1,
number_fmt: collections.abc.Callable[[Any], str] | str | None = None,
text_color: str | None = None,
brighten_text: bool = True,
show_text: bool = True,
bold_text: bool = False,
box_shadow: bool = False,
tooltip: bool = False,
season: Any = None,
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column of circles (or squares) sized and colored by value, by a color column, or by team.
A bubble is the value's share of the column's largest magnitude, up to 100 pixels across.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable (ranges and per-row colors are read from it). |
shape | Literal['circles', 'squares'] | "circles" or "squares". |
colors | collections.abc.Sequence[str] | Hex colors forming the scale from the column's minimum to its maximum. |
color_ref | str | None | A column of data holding each row's bubble color: hex, a CSS color name, or rgb()/hsl(); any other value is warned about once and that row keeps the scale color. |
team_col | str | None | A column of team values; each bubble takes that team's color (which). Teams that do not resolve keep the scale color. |
league | str | None | The SDV league key, e.g. "nfl"; needed by team_col. |
which | Literal['primary', 'secondary'] | "primary" or "secondary" team color. |
color_by | str | None | Another numeric column whose values set the colors and sizes. |
min_value | float | None | The value of an empty bubble; None measures from zero. |
max_value | float | None | The value of a 100-pixel bubble; None for the column's largest magnitude. Sizes are clamped to 0-100 pixels, as data bars are to their track. |
opacity | float | The bubble's opacity, 0 to 1. |
bias | float | Spacing of the scale's colors; above 1 spreads the high end (grDevices::colorRamp). |
number_fmt | collections.abc.Callable[[Any], str] | str | None | A function of the value returning its text, or a format spec such as ",.1f". |
text_color | str | None | The text color; None for black, or white on a dark bubble. |
brighten_text | bool | Switch the text to black or white when text_color is unreadable on the bubble. |
show_text | bool | Show the value inside the bubble. |
bold_text | bool | Bold text. |
box_shadow | bool | A drop shadow under each bubble. |
tooltip | bool | Give each cell a title (hover text) of its formatted value. |
season | Any | One season whose team colors to use; None for today's. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of team_col, as in resolve. |
strict | bool | Raise UnresolvedTeamError instead of warning when a team does not resolve. |
**column_kwargs | Any | Passed to reactable.Column; id names the column drawn. |
Returns
reactable.Column — The column, with html=True and a cell renderer.
Raises
InputError: (a ValueError) Ifshapeis not "circles"/"squares",opacityis outside [0, 1],biasis not positive,team_colcomes withoutleague, orcolor_refandteam_colare both given.ValueError: Ifcolorsare not hex colors, or a named column is not indata.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a team does not resolve.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_bubble_grid
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "wins": [15, 13, 12]})
Reactable(df, columns=[reactable_sdv_bubble_grid(df, team_col="team", league="nfl", id="wins")])
See also
reactable_sdv_color_scales
reactable_sdv_color_scales(
data: Any,
*,
colors: collections.abc.Sequence[str] = ('#15607A', '#FFFFFF', '#FA8C00'),
color_ref: str | None = None,
team_col: str | None = None,
league: str | None = None,
which: Literal['primary', 'secondary'] = 'primary',
color_by: str | None = None,
opacity: float = 1,
bias: float = 1,
min_value: float | None = None,
max_value: float | None = None,
even_breaks: bool = False,
number_fmt: collections.abc.Callable[[Any], str] | str | None = None,
text_color: str | None = None,
brighten_text: bool = True,
show_text: bool = True,
bold_text: bool = False,
span: bool | str | collections.abc.Sequence[str] = False,
tooltip: bool = False,
season: Any = None,
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column whose cell backgrounds are filled on a color scale, by a color column, or in team colors.
reactable_sdv_color_tiles without the tile; the text stays readable.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable (ranges and per-row colors are read from it). |
colors | collections.abc.Sequence[str] | Hex colors forming the scale from the column's minimum to its maximum. |
color_ref | str | None | A column of data holding each row's fill color: hex, a CSS color name, or rgb()/hsl(); any other value is warned about once and that row keeps the scale color. |
team_col | str | None | A column of team values; each cell takes that team's color (which). Teams that do not resolve keep the scale color. |
league | str | None | The SDV league key, e.g. "nfl"; needed by team_col. |
which | Literal['primary', 'secondary'] | "primary" or "secondary" team color. |
color_by | str | None | Another numeric column whose values set the colors. |
opacity | float | The fill's opacity, 0 to 1. |
bias | float | Spacing of the scale's colors; above 1 spreads the high end (grDevices::colorRamp). |
min_value | float | None | The value at the scale's first color; at most the column's minimum. |
max_value | float | None | The value at the scale's last color; at least the column's maximum. |
even_breaks | bool | Color by quantile bucket (as many as colors) instead of by value. |
number_fmt | collections.abc.Callable[[Any], str] | str | None | A function of the value returning its text, or a format spec such as ",.1f". |
text_color | str | None | The text color; None for black, or white on a dark fill. |
brighten_text | bool | Switch the text to black or white when text_color is unreadable on the fill. |
show_text | bool | Show the value; False hides it. |
bold_text | bool | Bold text. |
span | bool | str | collections.abc.Sequence[str] | True scales every numeric column of data on one shared range; a column name or list of names scales those columns together (cells of other columns are left unfilled). |
tooltip | bool | Give each cell a title (hover text) of its formatted value. |
season | Any | One season whose team colors to use; None for today's. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of team_col, as in resolve. |
strict | bool | Raise UnresolvedTeamError instead of warning when a team does not resolve. |
**column_kwargs | Any | Passed to reactable.Column; id names the column drawn. |
Returns
reactable.Column — The column, with a style function (and a cell renderer when number_fmt or tooltip is given).
Raises
InputError: (a ValueError) Ifopacityis outside [0, 1],biasis not positive,min_valueis above the column's minimum ormax_valuebelow its maximum (when theReactableis built),spannames a non-numeric column,team_colcomes withoutleague, orcolor_refandteam_colare both given.ValueError: Ifcolorsare not hex colors, or a named column is not indata.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a team does not resolve.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_color_scales
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "wins": [15, 13, 12]})
Reactable(df, columns=[reactable_sdv_color_scales(df, team_col="team", league="nfl", id="wins")])
See also
reactable_sdv_color_tiles
reactable_sdv_color_tiles(
data: Any,
*,
colors: collections.abc.Sequence[str] = ('#15607A', '#FFFFFF', '#FA8C00'),
color_ref: str | None = None,
team_col: str | None = None,
league: str | None = None,
which: Literal['primary', 'secondary'] = 'primary',
color_by: str | None = None,
opacity: float = 1,
bias: float = 1,
min_value: float | None = None,
max_value: float | None = None,
even_breaks: bool = False,
number_fmt: collections.abc.Callable[[Any], str] | str | None = None,
text_color: str | None = None,
brighten_text: bool = True,
show_text: bool = True,
bold_text: bool = False,
span: bool | str | collections.abc.Sequence[str] = False,
box_shadow: bool = False,
tooltip: bool = False,
season: Any = None,
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column of rounded tiles filled on a color scale, by a color column, or in the row's team color.
The text on each tile stays readable.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable (ranges and per-row colors are read from it). |
colors | collections.abc.Sequence[str] | Hex colors forming the scale from the column's minimum to its maximum. |
color_ref | str | None | A column of data holding each row's fill color: hex, a CSS color name, or rgb()/hsl(); any other value is warned about once and that row keeps the scale color. |
team_col | str | None | A column of team values; each tile takes that team's color (which). Teams that do not resolve keep the scale color. |
league | str | None | The SDV league key, e.g. "nfl"; needed by team_col. |
which | Literal['primary', 'secondary'] | "primary" or "secondary" team color. |
color_by | str | None | Another numeric column whose values set the colors. |
opacity | float | The fill's opacity, 0 to 1. |
bias | float | Spacing of the scale's colors; above 1 spreads the high end (grDevices::colorRamp). |
min_value | float | None | The value at the scale's first color; at most the column's minimum. |
max_value | float | None | The value at the scale's last color; at least the column's maximum. |
even_breaks | bool | Color by quantile bucket (as many as colors) instead of by value. |
number_fmt | collections.abc.Callable[[Any], str] | str | None | A function of the value returning its text, or a format spec such as ",.1f". |
text_color | str | None | The text color; None for black, or white on a dark tile. |
brighten_text | bool | Switch the text to black or white when text_color is unreadable on the tile. |
show_text | bool | Show the value; False leaves a plain tile. |
bold_text | bool | Bold text. |
span | bool | str | collections.abc.Sequence[str] | True scales every numeric column of data on one shared range; a column name or list of names scales those columns together (cells of other columns are left unfilled). |
box_shadow | bool | A drop shadow under each tile. |
tooltip | bool | Give each cell a title (hover text) of its formatted value. |
season | Any | One season whose team colors to use; None for today's. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of team_col, as in resolve. |
strict | bool | Raise UnresolvedTeamError instead of warning when a team does not resolve. |
**column_kwargs | Any | Passed to reactable.Column; id names the column drawn. |
Returns
reactable.Column — The column, with html=True and a cell renderer.
Raises
InputError: (a ValueError) Ifopacityis outside [0, 1],biasis not positive,min_valueis above the column's minimum ormax_valuebelow its maximum (when theReactableis built),spannames a non-numeric column,team_colcomes withoutleague, orcolor_refandteam_colare both given.ValueError: Ifcolorsare not hex colors, or a named column is not indata.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a team does not resolve.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_color_tiles
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "epa": [0.12, 0.18, 0.21]})
Reactable(df, columns=[reactable_sdv_color_tiles(df, number_fmt=".2f", id="epa")])
See also
reactable_sdv_cols_label
reactable_sdv_cols_label(
data: Any,
*,
league: str,
variant: str = 'default',
height: Any = 30,
season: Any = None,
mark_type: str = 'logo',
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
**column_kwargs: Any,
) -> list[reactable.models.Column]
One reactable column per team-named column of data (a KC column, a BUF column, ...), its header
the team's mark.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable. Pass only the team-named columns (df[["KC", "BUF"]]) to avoid a warning for the others. |
league | str | The SDV league key, e.g. "nfl". |
variant | str | "default", "dark", or a named variant from marks(). |
height | Any | The image height in pixels. |
season | Any | One season whose marks to show; None for today's. |
mark_type | str | "logo" or "wordmark". |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of the column names, as in resolve: "auto" tries each in order; NHL stats ids need "nhl_id". |
strict | bool | Raise UnresolvedTeamError instead of warning when a column name does not resolve. |
**column_kwargs | Any | Passed to every reactable.Column. |
Returns
list[reactable.Column] — A column (id = the column name, an empty name, the mark as header) for each column whose name resolves; the others are left out, with one SdvplotWarning.
Raises
InputError: (a ValueError) Ifmark_typeis not "logo"/"wordmark",heightis not a number of pixels of at least 1,league,id_systemorvariantis unknown, orseasonis not one year or is outside the seasons sdvplot knows for the league.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a column name does not resolve.OfflineError: If the logo manifest cannot be downloaded and no cached copy exists (a DownloadError, also an OSError, when the CDN answers with an error status).UnsafeDownloadError: (an OSError) If the manifest download is refused: larger than the byte cap, past the deadline, or redirected away from https.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_cols_label
df = pd.DataFrame(
{
"team": ["KC", "BUF", "BAL"],
"espn_id": ["3139477", "3918298", "3916387"],
"wins": [12, 10, 9],
}
)
Reactable(df, columns=reactable_sdv_cols_label(df, league="nfl"))
See also
reactable_sdv_data_bars
reactable_sdv_data_bars(
data: Any,
*,
fill_color: str | collections.abc.Sequence[str] = '#15607A',
fill_color_ref: str | None = None,
team_col: str | None = None,
league: str | None = None,
which: Literal['primary', 'secondary'] = 'primary',
fill_by: str | None = None,
fill_opacity: float = 1,
bias: float = 1,
min_value: float | None = None,
max_value: float | None = None,
align: Literal['left', 'right'] = 'left',
text_position: Literal['inside-end', 'outside-end', 'inside-base', 'outside-base', 'center', 'above', 'none'] = 'inside-end',
text_color: str | None = None,
brighten_text: bool = True,
bold_text: bool = False,
number_fmt: collections.abc.Callable[[Any], str] | str | None = None,
mark: Literal['logo', 'headshot', 'wordmark'] | None = None,
mark_col: str | None = None,
mark_height: float = 20,
round_edges: bool = False,
bar_height: float | None = None,
background: str = '#EEEEEE',
gradient: bool = False,
pos_neg: bool = False,
box_shadow: bool = False,
tooltip: bool = False,
season: Any = None,
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column of horizontal bars sized by value, in a scale color, a color column or the team color.
Each bar is the value's share of the column's largest magnitude, optionally with a logo, headshot or wordmark on it.
Negative values (or pos_neg=True) split the cell at zero: negative bars grow left from a center line, positive
bars right, colored by the first and last of two fill_color colors.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable (ranges and per-row colors are read from it). |
fill_color | str | collections.abc.Sequence[str] | One color, or several colors forming a scale from the column's minimum to its maximum. |
fill_color_ref | str | None | A column of data holding each row's bar color: hex, a CSS color name, or rgb()/hsl(); any other value is warned about once and that row keeps the scale color. |
team_col | str | None | A column of team values; each bar takes that team's color (which). Teams that do not resolve keep the scale color. |
league | str | None | The SDV league key, e.g. "nfl"; needed by team_col and mark. |
which | Literal['primary', 'secondary'] | "primary" or "secondary" team color. |
fill_by | str | None | Another numeric column whose values set the bar lengths and colors (a text column is an error). |
fill_opacity | float | The bar's opacity, 0 to 1. |
bias | float | Spacing of the scale's colors; above 1 spreads the high end (grDevices::colorRamp). |
min_value | float | None | The value of an empty bar; None measures from zero. |
max_value | float | None | The value of a full bar; None for the column's largest magnitude. Bars are clamped to 0-100% of the track, so a value beyond max_value draws a full bar. |
align | Literal['left', 'right'] | "left" or "right": the side bars grow from. |
text_position | Literal['inside-end', 'outside-end', 'inside-base', 'outside-base', 'center', 'above', 'none'] | "inside-end", "outside-end", "inside-base", "outside-base", "center", "above" or "none" ("none" keeps the value as visually hidden text for screen readers). |
text_color | str | None | The text color (hex, a CSS color name, or rgb()/hsl()); None for black, or white on a dark bar. |
brighten_text | bool | Switch text inside a bar to black or white when text_color is unreadable on it. |
bold_text | bool | Bold text. |
number_fmt | collections.abc.Callable[[Any], str] | str | None | A function of the value returning its text, or a format spec such as ",.1f". |
mark | Literal['logo', 'headshot', 'wordmark'] | None | "logo", "headshot" or "wordmark": an image at the end of each bar. |
mark_col | str | None | The column the mark is read from; defaults to team_col. Headshots need ESPN athlete ids. |
mark_height | float | The mark's height in pixels. |
round_edges | bool | Round the bar's ends. |
bar_height | float | None | The bar's height in pixels; None for 18 (5 with text_position="above"). |
background | str | The color of the empty track behind each bar (hex, a CSS color name, or rgb()/hsl()). |
gradient | bool | Fill each bar with a left-to-right gradient of fill_color (two colors or more). |
pos_neg | bool | Split every cell at zero even when no value is negative. |
box_shadow | bool | A drop shadow under each bar. |
tooltip | bool | Give each cell a title (hover text) of its formatted value. |
season | Any | One season whose team colors and marks to use; None for today's. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of team_col/mark_col, as in resolve. |
strict | bool | Raise UnresolvedTeamError instead of warning when a team does not resolve. |
**column_kwargs | Any | Passed to reactable.Column; id names the column drawn. |
Returns
reactable.Column — The column, with html=True and a cell renderer.
Raises
InputError: (a ValueError) If an option is not one of its choices, an opacity is outside [0, 1],fill_coloris not hex colors,gradienthas fewer than two colors,team_colormarkcomes withoutleague, orfill_color_refandteam_colare both given.ValueError: If a named column is not indata.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a team does not resolve.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_data_bars
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "wins": [15, 13, 12]})
Reactable(df, columns=[reactable_sdv_data_bars(df, team_col="team", league="nfl", mark="logo", id="wins")])
See also
reactable_sdv_frame
reactable_sdv_frame(
table: Any,
*,
title: Any = None,
subtitle: Any = None,
source: Any = None,
legend: Any = None,
font: str | None = None,
align: str = 'left',
) -> htmltools._core.TagList
A Reactable with a title and subtitle above it and a legend and source line under it, in a Google font.
The result shows in a notebook just as a Reactable does (call reactable.embed_css() once first). Its
sizes are reactablefmtr's: a 32 px bold title, a 24 px bold subtitle and a 16 px source line, no margins; the
text color is inherited from the page rather than reactablefmtr's black, so a dark page keeps it readable.
Arguments
| Name | Type | Description |
|---|---|---|
table | Any | The reactable.Reactable. |
title | Any | The title text (or an htmltools tag). |
subtitle | Any | The subtitle text (or tag). |
source | Any | The source line under the table, e.g. "Data: sportsdataverse-py". |
legend | Any | A legend from reactable_sdv_legend or reactable_sdv_icon_legend (any htmltools tag), shown under the table. |
font | str | None | A Google Fonts family name, e.g. "Poppins" or "Roboto Condensed", for the title, table and source; None keeps the page's font. The font is loaded from fonts.googleapis.com when the page is shown. |
align | str | "left", "center" or "right", for the title, subtitle, legend and source. |
Returns
htmltools.TagList — The framed table.
Raises
InputError: (a ValueError) Ifalignis not "left", "center" or "right", orfontis not a font name.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_frame, reactable_sdv_legend
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "wins": [12, 10, 9]})
reactable_sdv_frame(
Reactable(df),
title="AFC leaders",
subtitle="2025 regular season",
source="Data: sportsdataverse-py",
legend=reactable_sdv_legend(colors=["#ffffff", "#1a9641"], labels=["fewer", "more"]),
font="Poppins",
)
See also
reactable_sdv_gauge
reactable_sdv_gauge(
data: Any,
*,
fill_color: str | collections.abc.Sequence[str] | None = None,
background: str = '#EEEEEE',
team_col: str | None = None,
league: str | None = None,
which: Literal['primary', 'secondary'] = 'primary',
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
season: Any = None,
na_color: str = '#b3b3b3',
min_value: float | None = None,
max_value: float | None = None,
show_min_max: bool = False,
number_fmt: collections.abc.Callable[[float], str] | str | None = None,
size: float = 1,
text_color: str | None = None,
bold_text: bool = False,
text_size: str | None = None,
bias: float = 1,
opacity: float = 1,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column that draws each cell's number as a half-circle gauge (an inline SVG) with the value inside.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable: the gauged column's range (for the default scale and the color ramp) and team_col are read from it. |
fill_color | str | collections.abc.Sequence[str] | None | The gauge's CSS color, or several hex colors to ramp through from the column's smallest value to its largest (as reactablefmtr); None for reactablefmtr's "#15607A" (or the row's team color). |
background | str | The color of the gauge's unfilled track. |
team_col | str | None | A column of data holding each row's team: the gauge takes that team's color. |
league | str | None | The SDV league key of team_col's teams, e.g. "nhl"; required with team_col. |
which | Literal['primary', 'secondary'] | "primary" or "secondary" team color. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of team_col, as in resolve. |
strict | bool | Raise UnresolvedTeamError instead of warning when a team does not resolve. |
season | Any | One season for every row's team color, for teams whose colors changed; None for today's. |
na_color | str | The color for teams that do not resolve or have no color. |
min_value | float | None | The value of an empty gauge; None for 0. As in reactablefmtr, a cell's absolute value is what fills the gauge (-5 fills as 5); the printed value and the aria-label keep the sign. |
max_value | float | None | The value of a full gauge; None for the column's largest absolute value. Must be above min_value. |
show_min_max | bool | Print the scale's two ends under the gauge. |
number_fmt | collections.abc.Callable[[float], str] | str | None | How to print the value (and the ends): a function such as "{:.1%}".format, or a format spec such as ".3f"; None prints the number as is. |
size | float | The gauge's scale: 1 is 50 pixels wide (reactablefmtr's size = 1), 2 is 100. |
text_color | str | None | The value's color; None for the cell's text color. |
bold_text | bool | Print the value in bold. |
text_size | str | None | The value's CSS font size; None for the cell's. |
bias | float | The ramp's spacing (grDevices::colorRamp's bias): above 1 spreads the colors toward the high end. |
opacity | float | The fill's opacity, 0 to 1. |
**column_kwargs | Any | Passed to reactable.Column (id is required by reactable). |
Returns
reactable.Column — The column, with html=True and a cell renderer; each gauge is an <svg role="img"> whose aria-label gives the value and the scale. A missing value is left blank; text passes through.
Raises
InputError: (a ValueError) Ifsizeorbiasis not a positive number,opacityis outside [0, 1],min_value/max_valueis not a finite number ormin_valueis not belowmax_value,fill_colorholds several colors that are not hex colors, orteam_colis given withoutleague; ifleague,id_system,whichorseasonis unknown. When a cell is drawn: ifmin_valuealone is above the column's largest absolute value, or (withteam_col) the table has more rows thandata.ValueError: Ifteam_colis not a column ofdata.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a team does not resolve.
Example
import polars as pl
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_gauge
df = pl.DataFrame({"team": ["BOS", "TOR", "FLA"], "save_pct": [0.915, 0.902, 0.908]})
Reactable(df, columns=[reactable_sdv_gauge(df, id="save_pct", team_col="team", league="nhl",
min_value=0.88, max_value=0.93, number_fmt=".3f")])
See also
- Equivalent of reactablefmtr::gauge_chart (an SVG arc rather than nested divs, so the value sits on the cell's own background in any theme
- the "min" end reads the scale's real lower bound).
reactable_sdv_headshots
reactable_sdv_headshots(
*,
league: str,
height: Any = 40,
default_img: str | None = None,
id_system: str = 'espn',
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column that shows each cell's player id as the player's headshot.
Arguments
| Name | Type | Description |
|---|---|---|
league | str | The SDV league key, e.g. "nfl". |
height | Any | The image height in pixels. |
default_img | str | None | An image URL for ids without a headshot; None keeps their text. |
id_system | str | "espn" (ESPN athlete ids), "gsis" (NFL) or "league" (the league's own player id: nfl gsis, NBA and WNBA Stats ids, MLBAM, NHL), as in headshot_url. |
**column_kwargs | Any | Passed to reactable.Column (id is required by reactable). |
Returns
reactable.Column — The column, with html=True and a cell renderer.
Raises
InputError: (a ValueError) Ifheightis not a number of pixels of at least 1; when theReactableis built, ifleaguehas no ESPN headshots orid_systemis not valid forleague.OfflineError: When theReactableis built, ifid_systemis "gsis" and the nflverse player table cannot be downloaded and no cached copy exists (a DownloadError, also an OSError, for an HTTP error status).UnsafeDownloadError: (an OSError) When theReactableis built, ifid_systemis "gsis" and the player table download is refused: larger than the byte cap, past the deadline, or redirected away from https.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_headshots
df = pd.DataFrame(
{
"team": ["KC", "BUF", "BAL"],
"espn_id": ["3139477", "3918298", "3916387"],
"wins": [12, 10, 9],
}
)
Reactable(df, columns=[reactable_sdv_headshots(league="nfl", id="espn_id", name="")])
See also
reactable_sdv_highlight
reactable_sdv_highlight(
data: Any,
*,
which: Literal['max', 'min', 'min_max'] = 'max',
font_color: str | tuple[str, str] | None = None,
highlighter: str | tuple[str | None, str | None] | None = None,
tooltip: bool = False,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column whose highest (or lowest, or both) values are bold, in a color, optionally on a highlight.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable (the column's extremes are read from it). |
which | Literal['max', 'min', 'min_max'] | "max", "min", or "min_max" for both: which extreme to highlight. (Unlike the team-color which of the other formatters, "primary"/"secondary", this is reactablefmtr's highlight_max/_min/_min_max.) |
font_color | str | tuple[str, str] | None | The CSS text color; None for green on the maximum and red on the minimum. For "min_max", a (min, max) pair. |
highlighter | str | tuple[str | None, str | None] | None | A CSS background color, or a (min, max) pair for "min_max"; None for no background. |
tooltip | bool | Give each cell a title (hover text) of its value. |
**column_kwargs | Any | Passed to reactable.Column; id names the column drawn. |
Returns
reactable.Column — The column, with a style function (and a cell renderer when tooltip is on).
Raises
InputError: (a ValueError) Ifwhichis unknown, a pair is not two values, or a color is not a hex color, a CSS color name, or rgb()/hsl().
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_highlight
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "wins": [15, 13, 12]})
Reactable(df, columns=[reactable_sdv_highlight(df, which="min_max", id="wins")])
See also
reactable_sdv_icon_assign
reactable_sdv_icon_assign(
data: Any,
*,
icon: str = 'circle',
fill_color: str = '#15607A',
empty_color: str = '#EEEEEE',
fill_opacity: float = 1,
empty_opacity: float = 1,
align_icons: Literal['left', 'right', 'center'] = 'left',
icon_size: float = 16,
buckets: int | None = None,
number_fmt: collections.abc.Callable[[Any], str] | str | None = None,
seq_by: float = 1,
show_values: Literal['none', 'left', 'right', 'above', 'below'] = 'none',
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column that repeats an icon, filled up to the value: a rating in stars, a count in dots.
A value of 3 in a column whose largest value is 5 shows three filled icons and two empty ones (or, with
buckets, the value's quantile bucket out of buckets).
The icons are inline SVG; see reactable_sdv_icon_sets for the names.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable (the column's maximum is read from it). |
icon | str | The icon's name. |
fill_color | str | The hex color of a filled icon. |
empty_color | str | The hex color of an empty icon. |
fill_opacity | float | The filled icons' opacity, 0 to 1. |
empty_opacity | float | The empty icons' opacity, 0 to 1. |
align_icons | Literal['left', 'right', 'center'] | "left", "right" or "center". |
icon_size | float | The icon's size in pixels. |
buckets | int | None | Cut the column into this many quantile buckets and fill one icon per bucket reached. |
number_fmt | collections.abc.Callable[[Any], str] | str | None | A function of the value returning its text, or a format spec such as ",.1f". |
seq_by | float | One icon per this many units of value (values are rounded half up first). A cell draws at most 100 icons (with a warning); a column that would need more than 1,000 is an error. |
show_values | Literal['none', 'left', 'right', 'above', 'below'] | "none", or where to show the value: "left", "right", "above" or "below". |
**column_kwargs | Any | Passed to reactable.Column; id names the column drawn. |
Returns
reactable.Column — The column, with html=True and a cell renderer.
Raises
InputError: (a ValueError) Ificon,align_iconsorshow_valuesis unknown, an opacity is outside [0, 1],bucketsis not a positive whole number, orseq_byis not positive.ValueError: If a color is not a hex color.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_icon_assign
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "titles": [4, 0, 2]})
Reactable(df, columns=[reactable_sdv_icon_assign(df, icon="star", show_values="right", id="titles")])
See also
reactable_sdv_icon_legend
reactable_sdv_icon_legend(
*,
icons: Any,
colors: Any,
labels: Any,
title: Any = None,
footer: Any = None,
) -> htmltools._core.Tag
An icon legend: each icon, in its color, before its label, for reactable_sdv_frame(legend=...).
Arguments
| Name | Description |
|---|---|
icons | One shape per entry: "circle", "square", "triangle", "diamond" or "star" (drawn as inline SVG, no icon font), or a single shape for all. |
colors | One hex color per entry, or a single color for all. |
labels | One label per entry. |
title | Text above the icons. |
footer | Small grey text under them. |
Returns
htmltools.Tag — The legend.
Raises
InputError: (a ValueError) If a shape is unknown, a color is not a hex color, oricons/colorsdo not have one entry per label.
Example
from sdvplot.reactable import reactable_sdv_icon_legend
reactable_sdv_icon_legend(icons="circle", colors=["#1a9641", "#d7191c"], labels=["won", "lost"])
See also
reactable_sdv_icon_sets
reactable_sdv_icon_sets(
data: Any,
*,
icons: str | collections.abc.Sequence[str] = ('circle',),
colors: collections.abc.Sequence[str] = ('#15607A', '#B0B0B0', '#FA8C00'),
opacity: float = 1,
icon_position: Literal['left', 'right', 'above', 'below', 'over'] = 'right',
icon_ref: str | None = None,
icon_size: float = 16,
icon_color_ref: str | None = None,
number_fmt: collections.abc.Callable[[Any], str] | str | None = None,
tooltip: bool = False,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column that puts an icon beside each number, chosen by the value's quantile bucket.
The column is cut into as many buckets as icons (and as colors); each value takes its bucket's icon and
color.
The icons are inline SVG: circle, square, diamond, triangle (triangle-up), triangle-down, arrow
(arrow-right), arrow-up, arrow-down, arrow-left, chevron-up, chevron-down, star, check, x, flag, minus, plus,
heart and person.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable (buckets are read from it). |
icons | str | collections.abc.Sequence[str] | One icon name, or several from the lowest bucket to the highest. |
colors | collections.abc.Sequence[str] | Hex colors from the lowest bucket to the highest. |
opacity | float | The icons' opacity, 0 to 1. |
icon_position | Literal['left', 'right', 'above', 'below', 'over'] | "right", "left", "above", "below", or "over" (the icon replaces the value). |
icon_ref | str | None | A column of data holding each row's icon name (overrides icons); a missing value draws no icon. |
icon_size | float | The icon's size in pixels. |
icon_color_ref | str | None | A column of data holding each row's icon color (overrides colors): hex, a CSS color name, or rgb()/hsl(); a missing value or any other value (warned about once) draws no icon. |
number_fmt | collections.abc.Callable[[Any], str] | str | None | A function of the value returning its text, or a format spec such as ",.1f". |
tooltip | bool | Give each cell a title (hover text) of its formatted value. |
**column_kwargs | Any | Passed to reactable.Column; id names the column drawn. |
Returns
reactable.Column — The column, with html=True and a cell renderer.
Raises
InputError: (a ValueError) If an icon oricon_positionis unknown, oropacityis outside [0, 1].ValueError: Ifcolorsare not hex colors, or a named column is not indata.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_icon_sets
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "wins": [15, 13, 12]})
Reactable(df, columns=[reactable_sdv_icon_sets(df, icons=("arrow-down", "minus", "arrow-up"), id="wins")])
See also
reactable_sdv_icon_trend
reactable_sdv_icon_trend(
data: Any,
*,
icons: Literal['arrow', 'chevron', 'triangle'] = 'arrow',
colors: collections.abc.Sequence[str] = ('#15607A', '#767676', '#B35900'),
icon_position: Literal['left', 'right', 'above', 'below', 'over'] = 'right',
icon_size: float = 16,
show_zero_label: bool = False,
number_fmt: collections.abc.Callable[[Any], str] | str | None = None,
opacity: float = 1,
text_color: str | None = None,
bold_text: bool = False,
tooltip: bool = False,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column that marks each change with an up arrow, a down arrow or a dash, the value colored to match.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable. |
icons | Literal['arrow', 'chevron', 'triangle'] | "arrow", "chevron" or "triangle". |
colors | collections.abc.Sequence[str] | Three hex colors: down, zero, up. The default is reactablefmtr's #15607A with #767676 and #B35900, both 4.5:1 or better on white, in place of reactablefmtr's #B2B2B2 and #FA8C00 (about 2.1:1 and 2.4:1, too faint for the text, which takes these colors). |
icon_position | Literal['left', 'right', 'above', 'below', 'over'] | "right", "left", "above", "below", or "over" (the icon replaces the value). |
icon_size | float | The icon's size in pixels. |
show_zero_label | bool | Show the value when it is zero (otherwise only the dash is drawn, and the zero is kept as visually hidden text for screen readers). |
number_fmt | collections.abc.Callable[[Any], str] | str | None | A function of the value returning its text, or a format spec such as "+.1f". |
opacity | float | The icons' opacity, 0 to 1. |
text_color | str | None | One color for every value's text; None colors it like its icon. |
bold_text | bool | Bold text. |
tooltip | bool | Give each cell a title (hover text) of its formatted value. |
**column_kwargs | Any | Passed to reactable.Column; id names the column drawn. |
Returns
reactable.Column — The column, with html=True and a cell renderer.
Raises
InputError: (a ValueError) Ificonsoricon_positionis unknown,colorsis not three colors, oropacityis outside [0, 1].ValueError: Ifcolorsare not hex colors.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_icon_trend
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "win_change": [4, 0, -3]})
Reactable(df, columns=[reactable_sdv_icon_trend(df, number_fmt="+d", id="win_change")])
See also
reactable_sdv_legend
reactable_sdv_legend(
*,
colors: Any,
labels: Any = None,
bins: int | None = None,
title: Any = None,
footer: Any = None,
) -> htmltools._core.Tag
A color legend: a row of swatches with a label under each, for reactable_sdv_frame(legend=...).
Arguments
| Name | Type | Description |
|---|---|---|
colors | Any | The legend's colors, low to high, as hex strings. |
labels | Any | One label per swatch (numbers or text); None for swatches alone. |
bins | int | None | The number of swatches, spread evenly along colors as a ramp (reactablefmtr's bins); None for one swatch per color. |
title | Any | Text above the swatches. |
footer | Any | Small grey text under them. |
Returns
htmltools.Tag — The legend.
Raises
InputError: (a ValueError) Ifcolorsis empty or not hex colors,binsis not a whole number of at least 2, orlabelsdoes not have one entry per swatch.
Example
from sdvplot.reactable import reactable_sdv_legend
reactable_sdv_legend(colors=["#15607a", "#ffffff", "#fa8c00"], bins=5, labels=[-0.2, -0.1, 0, 0.1, 0.2],
title="EPA per play", footer="lower is better on defense")
See also
reactable_sdv_logos
reactable_sdv_logos(
*,
league: str,
variant: str = 'default',
height: Any = 30,
default_img: str | None = None,
season: Any = None,
include_name: bool = False,
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column that shows each cell's team as its logo.
Arguments
| Name | Type | Description |
|---|---|---|
league | str | The SDV league key, e.g. "nfl". |
variant | str | "default", "dark", or a named variant from marks(). |
height | Any | The image height in pixels. |
default_img | str | None | An image URL for values that do not resolve; None keeps their text. |
season | Any | One season whose marks every cell shows; None for today's. |
include_name | bool | Keep the cell's text after the logo. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of the column's values, as in resolve: "auto" tries each in order; NHL stats ids need "nhl_id". |
strict | bool | Raise UnresolvedTeamError (when the Reactable is built) instead of warning when a value does not resolve. |
**column_kwargs | Any | Passed to reactable.Column: id (the data column, required by reactable), name, width, ... |
Returns
reactable.Column — The column, with html=True and a cell renderer.
Raises
InputError: (a ValueError) Ifheightis not a number of pixels of at least 1, orseasonis not one year or is outside the seasons sdvplot knows for the league; when theReactableis built, ifleague,id_systemorvariantis unknown.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a value does not resolve, when theReactableis built.OfflineError: When theReactableis built, if the logo manifest cannot be downloaded and no cached copy exists (a DownloadError, also an OSError, when the CDN answers with an error status).UnsafeDownloadError: (an OSError) When theReactableis built, if the manifest download is refused: larger than the byte cap, past the deadline, or redirected away from https.
Example
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_logos
import pandas as pd
df = pd.DataFrame(
{
"team": ["KC", "BUF", "BAL"],
"espn_id": ["3139477", "3918298", "3916387"],
"wins": [12, 10, 9],
}
)
Reactable(df, columns=[reactable_sdv_logos(league="nfl", id="team", name="")])
See also
reactable_sdv_merge_column
reactable_sdv_merge_column(
data: Any,
*,
merged_name: str,
merged_position: Literal['right', 'left', 'above', 'below'] = 'right',
merged_size: float = 12,
merged_color: str = '#777',
merged_weight: Literal['normal', 'bold'] = 'normal',
size: float = 14,
color: str | None = None,
weight: Literal['normal', 'bold'] = 'bold',
spacing: float = 0,
mark: Literal['logo', 'headshot', 'wordmark'] | None = None,
mark_col: str | None = None,
team_col: str | None = None,
league: str | None = None,
mark_height: float = 30,
tooltip: bool = False,
season: Any = None,
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column that shows a second column's value beside or below each value, after an optional mark.
A player and his team, a team and its record; the mark is the row's logo, headshot or wordmark.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable (the merged values are read from it). |
merged_name | str | The column of data merged into this one (hide it with Column(show=False) if it is shown). |
merged_position | Literal['right', 'left', 'above', 'below'] | "right", "left", "above" or "below". |
merged_size | float | The merged text's size in pixels. |
merged_color | str | The merged text's color (hex, a CSS color name, or rgb()/hsl()). |
merged_weight | Literal['normal', 'bold'] | "normal" or "bold" for the merged text. |
size | float | The main text's size in pixels. |
color | str | None | The main text's color (hex, a CSS color name, or rgb()/hsl()); None inherits the table's. |
weight | Literal['normal', 'bold'] | "normal" or "bold" for the main text. |
spacing | float | Extra pixels between the two values. |
mark | Literal['logo', 'headshot', 'wordmark'] | None | "logo", "headshot" or "wordmark": an image before the text. |
mark_col | str | None | The column the mark is read from; defaults to team_col, then this column. Headshots need ESPN athlete ids. |
team_col | str | None | A column of team values for the logo or wordmark. |
league | str | None | The SDV league key, e.g. "nfl"; needed by mark. |
mark_height | float | The mark's height in pixels. |
tooltip | bool | Give each cell a title (hover text) of its value and the merged value. |
season | Any | One season whose marks to use; None for today's. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of the mark's column, as in resolve. |
strict | bool | Raise UnresolvedTeamError instead of warning when a team does not resolve. |
**column_kwargs | Any | Passed to reactable.Column; id names the column drawn. |
Returns
reactable.Column — The column, with html=True and a cell renderer.
Raises
InputError: (a ValueError) Ifmerged_position, a weight ormarkis unknown, a color is not a color, ormarkcomes withoutleagueor a column to read it from.ValueError: If a named column is not indata.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a team does not resolve.
Example
import pandas as pd
from reactable import Column, Reactable
from sdvplot.reactable import reactable_sdv_merge_column
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "record": ["15-2", "13-4", "12-5"]})
Reactable(
df,
columns=[
reactable_sdv_merge_column(df, merged_name="record", merged_position="below", mark="logo",
team_col="team", league="nfl", id="team"),
Column(id="record", show=False),
],
)
See also
reactable_sdv_pill_buttons
reactable_sdv_pill_buttons(
data: Any,
*,
colors: str | collections.abc.Sequence[str] = '#15607A',
color_ref: str | None = None,
team_col: str | None = None,
league: str | None = None,
which: Literal['primary', 'secondary'] = 'primary',
opacity: float = 1,
number_fmt: collections.abc.Callable[[Any], str] | str | None = None,
text_color: str | None = None,
brighten_text: bool = True,
show_text: bool = True,
bold_text: bool = False,
box_shadow: bool = False,
tooltip: bool = False,
season: Any = None,
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column whose values sit in rounded pills, in a scale color, a color column or the team color.
Numbers are colored on the scale, text takes the first color.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable (ranges and per-row colors are read from it). |
colors | str | collections.abc.Sequence[str] | One hex color, or several forming a scale from the column's minimum to its maximum (numbers only). |
color_ref | str | None | A column of data holding each row's pill color: hex, a CSS color name, or rgb()/hsl(); any other value is warned about once and that row keeps the scale color. |
team_col | str | None | A column of team values; each pill takes that team's color (which). |
league | str | None | The SDV league key, e.g. "nfl"; needed by team_col. |
which | Literal['primary', 'secondary'] | "primary" or "secondary" team color. |
opacity | float | The pill's opacity, 0 to 1. |
number_fmt | collections.abc.Callable[[Any], str] | str | None | A function of the value returning its text, or a format spec such as ",.1f". |
text_color | str | None | The text color; None for black, or white on a dark pill. |
brighten_text | bool | Switch the text to black or white when text_color is unreadable on the pill. |
show_text | bool | Show the value; False leaves an empty pill. |
bold_text | bool | Bold text. |
box_shadow | bool | A drop shadow under each pill. |
tooltip | bool | Give each cell a title (hover text) of its formatted value. |
season | Any | One season whose team colors to use; None for today's. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of team_col, as in resolve. |
strict | bool | Raise UnresolvedTeamError instead of warning when a team does not resolve. |
**column_kwargs | Any | Passed to reactable.Column; id names the column drawn. |
Returns
reactable.Column — The column, with html=True and a cell renderer.
Raises
InputError: (a ValueError) Ifopacityis outside [0, 1],team_colcomes withoutleague, orcolor_refandteam_colare both given.ValueError: Ifcolorsare not hex colors, or a named column is not indata.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a team does not resolve.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_pill_buttons
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "conf": ["AFC West", "AFC East", "AFC North"]})
Reactable(df, columns=[reactable_sdv_pill_buttons(df, team_col="team", league="nfl", id="conf")])
See also
reactable_sdv_sparkbar
reactable_sdv_sparkbar(
data: Any,
*,
fill_color: str | None = None,
team_col: str | None = None,
league: str | None = None,
which: Literal['primary', 'secondary'] = 'primary',
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
season: Any = None,
na_color: str = '#b3b3b3',
fill_opacity: float = 1,
highlight_bars: collections.abc.Sequence[str] | collections.abc.Mapping[str, str] = (),
statline: str | None = None,
statline_color: str = 'red',
statline_label_size: str = '0.8em',
bandline: str | None = None,
bandline_color: str = 'red',
bandline_opacity: float = 0.2,
labels: collections.abc.Sequence[str] | str = (),
label_size: str = '0.8em',
decimals: int = 0,
min_value: float | None = None,
max_value: float | None = None,
height: float = 22,
width: float | None = None,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column that draws each cell's list of numbers as a small bar chart (an inline SVG).
Bars stand on zero: positive values rise from it, negative ones hang below it.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable; read only for team_col. The column itself holds one list per row; a missing entry leaves a gap, an empty, missing or non-list cell is left blank. |
fill_color | str | None | The bars' CSS color; None for reactablefmtr's "slategray" (or the row's team color). |
team_col | str | None | A column of data holding each row's team: the bars take that team's color. |
league | str | None | The SDV league key of team_col's teams, e.g. "wnba"; required with team_col. |
which | Literal['primary', 'secondary'] | "primary" or "secondary" team color. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of team_col, as in resolve. |
strict | bool | Raise UnresolvedTeamError instead of warning when a team does not resolve. |
season | Any | One season for every row's team color, for teams whose colors changed; None for today's. |
na_color | str | The color for teams that do not resolve or have no color. |
fill_opacity | float | The bars' opacity, 0 to 1. |
highlight_bars | collections.abc.Sequence[str] | collections.abc.Mapping[str, str] | Bars to recolor: a mapping such as {"max": "gold"} (reactablefmtr's highlight_bars(max = "gold")), or a sequence of "first", "last", "min", "max" drawn in red. |
statline | str | None | A dashed reference line at the series' "mean", "median", "min" or "max", labeled at its right. |
statline_color | str | The reference line's and its label's color. |
statline_label_size | str | The reference line label's CSS font size. |
bandline | str | None | A shaded band across the series' "innerquartiles" or "range". |
bandline_color | str | The band's color. |
bandline_opacity | float | The band's opacity, 0 to 1. |
labels | collections.abc.Sequence[str] | str | Values to print above their bars: "first", "last", "min", "max" or "all". |
label_size | str | The labels' CSS font size. |
decimals | int | Decimal places of the labels and the statline label. |
min_value | float | None | The value at the bottom of every cell's chart; None for the lower of 0 and the series' minimum. |
max_value | float | None | The value at the top of every cell's chart; None for the higher of 0 and the series' maximum. |
height | float | The chart's height in pixels. |
width | float | None | The chart's width in pixels; None for 100. |
**column_kwargs | Any | Passed to reactable.Column (id is required by reactable). |
Returns
reactable.Column — The column, with html=True and a cell renderer; each chart is an <svg role="img"> whose aria-label gives the number of bars, the minimum, the maximum and the last value.
Raises
InputError: (a ValueError) Asreactable_sdv_sparkline: a bad pixel size, opacity, option name, decimals or bounds, orteam_colwithoutleague; ifleague,id_system,whichorseasonis unknown. When a cell is drawn: asreactable_sdv_sparkline.ValueError: Ifteam_colis not a column ofdata.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a team does not resolve.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_sparkbar
df = pd.DataFrame({"team": ["LV", "NY"], "pts": [[88, 95, 79, 101], [92, 85, 99, 90]]})
Reactable(df, columns=[reactable_sdv_sparkbar(df, id="pts", team_col="team", league="wnba",
highlight_bars={"max": "gold"})])
See also
- Equivalent of reactablefmtr::react_sparkbar (drawn without dataui: no hover tooltips per bar, bars rooted at zero so the smallest bar still shows).
reactable_sdv_sparkline
reactable_sdv_sparkline(
data: Any,
*,
line_color: str | None = None,
team_col: str | None = None,
league: str | None = None,
which: Literal['primary', 'secondary'] = 'primary',
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
season: Any = None,
na_color: str = '#b3b3b3',
line_width: float = 1.5,
show_area: bool = False,
area_color: str | None = None,
area_opacity: float = 0.1,
highlight_points: collections.abc.Sequence[str] | collections.abc.Mapping[str, str] = (),
point_size: float = 1.5,
statline: str | None = None,
statline_color: str = 'red',
statline_label_size: str = '0.8em',
bandline: str | None = None,
bandline_color: str = 'red',
bandline_opacity: float = 0.2,
labels: collections.abc.Sequence[str] | str = (),
label_size: str = '0.8em',
decimals: int = 0,
min_value: float | None = None,
max_value: float | None = None,
height: float = 22,
width: float | None = None,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column that draws each cell's list of numbers as a sparkline (an inline SVG).
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable; read only for team_col. The column itself holds one list per row (a polars List column, or a pandas column of lists); a missing entry breaks the line, an empty, missing or non-list cell is left blank. |
line_color | str | None | The line's CSS color; None for reactablefmtr's "slategray" (or the row's team color). |
team_col | str | None | A column of data holding each row's team: the line (and area) take that team's color. |
league | str | None | The SDV league key of team_col's teams, e.g. "nba"; required with team_col. |
which | Literal['primary', 'secondary'] | "primary" or "secondary" team color. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of team_col, as in resolve. |
strict | bool | Raise UnresolvedTeamError instead of warning when a team does not resolve. |
season | Any | One season for every row's team color, for teams whose colors changed; None for today's. |
na_color | str | The color for teams that do not resolve or have no color. |
line_width | float | The line's stroke width in pixels. |
show_area | bool | Fill the area under the line. |
area_color | str | None | The area's color; None for the line's. |
area_opacity | float | The area's opacity, 0 to 1. |
highlight_points | collections.abc.Sequence[str] | collections.abc.Mapping[str, str] | Points to mark: a mapping such as {"min": "red", "max": "blue"} (reactablefmtr's highlight_points(min = "red", max = "blue")), or a sequence of names drawn in red. Names are "first", "last", "min", "max" and "all". |
point_size | float | The radius of a highlighted point, in pixels. |
statline | str | None | A dashed reference line at the series' "mean", "median", "min" or "max", labeled at its right. |
statline_color | str | The reference line's and its label's color. |
statline_label_size | str | The reference line label's CSS font size. |
bandline | str | None | A shaded band across the series' "innerquartiles" (25th to 75th percentile) or "range". |
bandline_color | str | The band's color. |
bandline_opacity | float | The band's opacity, 0 to 1. |
labels | collections.abc.Sequence[str] | str | Values to print by their point: names as for highlight_points ("all" labels every point). |
label_size | str | The labels' CSS font size. |
decimals | int | Decimal places of the labels and the statline label. |
min_value | float | None | The value at the bottom of every cell's chart; None for each series' own minimum. |
max_value | float | None | The value at the top of every cell's chart; None for each series' own maximum. |
height | float | The chart's height in pixels; the default 22 grows to 28 or 30 to make room for labels above the points, as in reactablefmtr. |
width | float | None | The chart's width in pixels; None for 100. |
**column_kwargs | Any | Passed to reactable.Column (id is required by reactable). |
Returns
reactable.Column — The column, with html=True and a cell renderer. Each chart is an <svg role="img"> whose aria-label (and <title> tooltip) gives the number of points, the minimum, the maximum and the last value.
Raises
InputError: (a ValueError) Ifheight/widthis not a number of pixels of at least 1, an opacity is outside [0, 1],statline/bandline/labels/highlight_pointsnames an unknown option,decimalsis not a whole number,line_width/point_sizeis not a positive number,min_value/max_valueis not a finite number ormin_valueis not belowmax_value, orteam_colis given withoutleague; ifleague,id_system,whichorseasonis unknown. When a cell is drawn: if one bound crosses the row's data, or (withteam_col) the table has more rows thandata.ValueError: Ifteam_colis not a column ofdata.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a team does not resolve.
Example
import polars as pl
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_sparkline
df = pl.DataFrame({"team": ["BOS", "NY"], "margin": [[12, -4, 8, 21], [3, 7, -10, 5]]})
Reactable(
df,
columns=[
reactable_sdv_sparkline(df, id="margin", team_col="team", league="nba",
highlight_points={"min": "red", "max": "blue"}, statline="mean"),
],
)
See also
- Equivalent of reactablefmtr::react_sparkline (drawn without dataui: no hover tooltips per point, a solid rather than hatched band, straight rather than cardinal-curve segments).
reactable_sdv_team_color_bar
reactable_sdv_team_color_bar(
data: Any,
team_col: str,
*,
league: str,
which: Literal['primary', 'secondary'] = 'primary',
max_value: float | None = None,
na_color: str = '#b3b3b3',
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column whose cells hold a bar in the row's team color, as long as the value's share of the maximum.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable (each row's team is read from it). |
team_col | str | The column of data holding the teams. |
league | str | The SDV league key, e.g. "nfl". |
which | Literal['primary', 'secondary'] | "primary" or "secondary" team color. |
max_value | float | None | The value that fills the whole cell; None for the column's maximum. |
na_color | str | The CSS color for teams that do not resolve or have no color. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of team_col, as in resolve: "auto" tries each in order; NHL stats ids need "nhl_id". |
strict | bool | Raise UnresolvedTeamError instead of warning when a team does not resolve. |
**column_kwargs | Any | Passed to reactable.Column; id names the styled column. |
Returns
reactable.Column — The column, with a style function.
Raises
InputError: (a ValueError) Ifleagueorid_systemis unknown, orwhichis not "primary"/"secondary".ValueError: Ifteam_colis not a column ofdata.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a team does not resolve.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_team_color_bar
df = pd.DataFrame(
{
"team": ["KC", "BUF", "BAL"],
"espn_id": ["3139477", "3918298", "3916387"],
"wins": [12, 10, 9],
}
)
Reactable(df, columns=[reactable_sdv_team_color_bar(df, "team", league="nfl", id="wins")])
See also
reactable_sdv_team_color_bg
reactable_sdv_team_color_bg(
data: Any,
team_col: str,
*,
league: str,
which: Literal['primary', 'secondary'] = 'primary',
alpha: float = 0.15,
na_color: str = '#b3b3b3',
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column whose cells are filled with the row's team color, mostly transparent.
Arguments
| Name | Type | Description |
|---|---|---|
data | Any | The pandas or polars DataFrame passed to Reactable (each row's team is read from it). |
team_col | str | The column of data holding the teams. |
league | str | The SDV league key, e.g. "nfl". |
which | Literal['primary', 'secondary'] | "primary" or "secondary" team color. |
alpha | float | The fill's opacity, 0 to 1. |
na_color | str | The hex color for teams that do not resolve or have no color. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of team_col, as in resolve: "auto" tries each in order; NHL stats ids need "nhl_id". |
strict | bool | Raise UnresolvedTeamError instead of warning when a team does not resolve. |
**column_kwargs | Any | Passed to reactable.Column; id names the styled column. |
Returns
reactable.Column — The column, with a style function.
Raises
InputError: (a ValueError) Ifalphais outside [0, 1],leagueorid_systemis unknown, orwhichis not "primary"/"secondary".ValueError: Ifteam_colis not a column ofdata, orna_coloris not a hex color.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a team does not resolve.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_team_color_bg
df = pd.DataFrame(
{
"team": ["KC", "BUF", "BAL"],
"espn_id": ["3139477", "3918298", "3916387"],
"wins": [12, 10, 9],
}
)
Reactable(df, columns=[reactable_sdv_team_color_bg(df, "team", league="nfl", id="team")])
See also
reactable_sdv_theme
reactable_sdv_theme(
name: str,
*,
mode: str = 'light',
font_size: float | None = None,
font_color: str | None = None,
header_font_size: float | None = None,
header_font_color: str | None = None,
background_color: str | None = None,
cell_padding: float | str | None = None,
centered: bool = False,
**theme_args: Any,
) -> reactable.models.Theme
One of reactablefmtr's 27 table themes, or any of the 122 surveyed registry themes (sdv_table_themes()).
A reactablefmtr name wins over a registry id. "espn", "fivethirtyeight" and "pff" are the
reactablefmtr ports; the surveyed look of those sites is "espn-site", "fivethirtyeight-site" and
"pff-site". A registry theme is built from its palette, fonts and sizes: the text, background, hairline,
stripe and hover colors, the header label style, the body font and the cell padding.
Pass the result to Reactable(theme=...). (reactable.options.theme would set it for every table in the
session, so the theme is returned rather than set.) The themes do not load a font: give
reactable_sdv_frame(font=...) a Google font for that.
Arguments
| Name | Type | Description |
|---|---|---|
name | str | The theme: "cerulean", "clean", "cosmo", "cyborg", "dark", "darkly", "default", "espn", "fivethirtyeight", "flatly", "hoverdark", "hoverlight", "journal", "lux", "midnight", "midnightblue", "minty", "no_lines", "nytimes", "pff", "sandstone", "sanfran", "slate", "spacelab", "sunrise", "superhero" or "void"; or a registry id such as "wikipedia", "datagolf" or "nejm". |
mode | str | "light" (default) or "dark". A reactablefmtr theme has no dark variant, so "dark" is accepted only for the themes that are dark already ("cyborg", "dark", "darkly", "hoverdark", "midnight", "midnightblue", "slate", "superhero") and raises for the rest. A registry theme raises when it is light-only. |
font_size | float | None | The body font size in pixels; None for the theme's. |
font_color | str | None | The body text color; None for the theme's. |
header_font_size | float | None | The header font size in pixels; None for the theme's. |
header_font_color | str | None | The header text color; None for the theme's. "hoverdark" and "hoverlight" have none. |
background_color | str | None | The table background; None for the theme's (most light themes have none: the page shows). |
cell_padding | float | str | None | The cell padding, pixels or a CSS string; None for the theme's. |
centered | bool | Center cell content vertically (useful with images). |
**theme_args | Any | The theme's own extra arguments, by their reactablefmtr names: "nytimes" border_color, border_width; "sanfran" cell_color, cell_border_width, cell_border_color, pagination_color; "void" border_color, border_width, header_border_color, header_border_width. |
Returns
reactable.Theme — The theme.
Raises
InputError: (a ValueError) Ifnameis neither a reactablefmtr theme nor a registry id (close matches are named),modeis not "light" or "dark",mode="dark"is asked of a light theme,centeredis not a bool, or an argument is not one the theme takes.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_theme
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "wins": [12, 10, 9]})
Reactable(df, theme=reactable_sdv_theme("espn"))
Reactable(df, theme=reactable_sdv_theme("midnight", font_size=13, centered=True))
Reactable(df, theme=reactable_sdv_theme("wikipedia"))
See also
reactable_sdv_theme_team
reactable_sdv_theme_team(
team: Any,
league: str,
*,
font_size: float | None = 15,
font_color: str | None = None,
header_font_size: float | None = 15,
header_font_color: str | None = None,
background_color: str | None = None,
cell_padding: float | str | None = 6,
centered: bool = False,
season: Any = None,
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
) -> reactable.models.Theme
A table theme in a team's colors: the header filled with the primary color over a rule in the secondary,
stripes, hover and the current page button tinted with the primary, and every text color readable on its fill.
Arguments
| Name | Type | Description |
|---|---|---|
team | Any | The team, any value resolve accepts (an abbreviation, a name, an id). |
league | str | The SDV league key, e.g. "nfl". |
font_size | float | None | The body font size in pixels. |
font_color | str | None | The body text color as a hex color; None for black or white, whichever reads better on the background. |
header_font_size | float | None | The header font size in pixels. |
header_font_color | str | None | The header text color as a hex color; None for black or white, whichever reads better on the primary. |
background_color | str | None | The table background as a hex color; None for white (the page shows through). |
cell_padding | float | str | None | The cell padding, pixels or a CSS string. |
centered | bool | Center cell content vertically (useful with images). |
season | Any | The season whose colors to use; None for today's. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of team, as in resolve. |
Returns
reactable.Theme — The theme.
Raises
InputError: (a ValueError) Ifleagueorid_systemis unknown,centeredis not a bool, orbackground_color,font_colororheader_font_coloris not a hex color.UnresolvedTeamError: (a ValueError) Ifteamdoes not resolve.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_theme_team
df = pd.DataFrame({"team": ["KC", "BUF", "BAL"], "wins": [12, 10, 9]})
Reactable(df, theme=reactable_sdv_theme_team("KC", "nfl"))
See also
reactable_sdv_wordmarks
reactable_sdv_wordmarks(
*,
league: str,
variant: str = 'default',
height: Any = 30,
default_img: str | None = None,
season: Any = None,
include_name: bool = False,
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
**column_kwargs: Any,
) -> reactable.models.Column
A reactable column that shows each cell's team as its wordmark.
Arguments
| Name | Type | Description |
|---|---|---|
league | str | The SDV league key, e.g. "nfl". |
variant | str | "default", "dark", or a named variant from marks(). |
height | Any | The image height in pixels. |
default_img | str | None | An image URL for values that do not resolve; None keeps their text. |
season | Any | One season whose marks every cell shows; None for today's. |
include_name | bool | Keep the cell's text after the wordmark. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of the column's values, as in resolve: "auto" tries each in order; NHL stats ids need "nhl_id". |
strict | bool | Raise UnresolvedTeamError (when the Reactable is built) instead of warning when a value does not resolve. |
**column_kwargs | Any | Passed to reactable.Column (id is required by reactable). |
Returns
reactable.Column — The column, with html=True and a cell renderer.
Raises
InputError: (a ValueError) Ifheightis not a number of pixels of at least 1, orseasonis not one year or is outside the seasons sdvplot knows for the league; when theReactableis built, ifleague,id_systemorvariantis unknown.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand a value does not resolve, when theReactableis built.OfflineError: When theReactableis built, if the logo manifest cannot be downloaded and no cached copy exists (a DownloadError, also an OSError, when the CDN answers with an error status).UnsafeDownloadError: (an OSError) When theReactableis built, if the manifest download is refused: larger than the byte cap, past the deadline, or redirected away from https.
Example
import pandas as pd
from reactable import Reactable
from sdvplot.reactable import reactable_sdv_wordmarks
df = pd.DataFrame(
{
"team": ["KC", "BUF", "BAL"],
"espn_id": ["3139477", "3918298", "3916387"],
"wins": [12, 10, 9],
}
)
Reactable(df, columns=[reactable_sdv_wordmarks(league="nfl", id="team")])