With numeric values in a gt table we can transform those to Roman numerals, rounding values as necessary.
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 undergo formatting. The default is all rows, resulting in all rows in targeted columns being formatted. Alternatively, we can supply a list of row indices.
None
case
str
Should Roman numerals should be rendered as uppercase ("upper") or lowercase ("lower") letters? By default, this is set to "upper".
'upper'
pattern
str
A formatting pattern that allows for decoration of the formatted value. The formatted value is represented by the {x} (which can be used multiple times, if needed) and all other characters will be interpreted as string literals.
The GT object is returned. This is the same object that the method is called on so that we can facilitate method chaining.
Examples
Let’s first create a DataFrame containing small numeric values and then introduce that to GT(). We’ll then format the roman column to appear as Roman numerals with the fmt_roman() method.