Wherever there is missing data (i.e., None values) customizable content may present better than the standard representation of missing values that would otherwise appear. The sub_missing() method allows for this replacement through its missing_text= argument. And by not supplying anything to missing_text=, an em dash will serve as a default indicator of missingness.
Parameters
Name
Type
Description
Default
columns
SelectExpr
The columns to target. Can either be a single column name or a series of column names provided in a list.
None
rows
int | list[int] | None
In conjunction with columns=, we can specify which of their rows should be scanned for missing values. The default is all rows, resulting in all rows in all targeted columns being considered for this substitution. Alternatively, we can supply a list of row indices.
None
missing_text
str | Text | None
The text to be used in place of missing values in the rendered table. We can optionally use the md() or html() helper functions to style the text as Markdown or to retain HTML elements in the text.
The GT object is returned. This is the same object that the method is called on so that we can facilitate method chaining.
Examples
Using a subset of the exibble dataset, let’s create a new table. The missing values in two selections of columns will be given different variations of replacement text (across two separate calls of sub_missing()).