GPTable
A Good Practice Table.
Stores data, text content, and content metadata for writing a table to Excel.
Attributes:
| Name | Type | Description |
|---|---|---|
table |
DataFrame
|
table to be written to an Excel workbook |
table_name |
str
|
name for table. Should be unique with no spaces and always begin with a letter, an underscore character, or a backslash. Use letters, numbers, periods, and underscore characters for the rest of the name. |
title |
str
|
title of the table |
subtitles |
(List[str], optional)
|
subtitles as a list of strings |
instructions |
(str, optional)
|
instructions on how to read the sheet. If not provided, defaults to "This worksheet contains one table. Some cells may refer to notes, which can be found on the notes worksheet." |
scope |
(str, optional)
|
description of scope/basis of data in table if not included in title |
source |
(str, optional)
|
description of the source of the data in table if not included in cover |
units |
(dict, optional)
|
units used in each (dict) column of table |
legend |
(list, optional)
|
descriptions of special notation used in table |
index_columns |
(dict, optional)
|
mapping an index level to a 0-indexed column as {level: column}. Default is a level two index in the first column ({2: 0}). |
additional_formatting |
(dict, optional)
|
table-specific formatting for columns, rows or individual cells |
add_legend(new_legend: Any) -> None
Add a single legend entry to the existing legend list.
add_subtitle(new_subtitle: Any) -> None
Add a single subtitle to the existing list of subtitles.
set_additional_formatting(new_formatting: List[Dict[str, Any]]) -> None
Set a dictionary of additional formatting to be applied to this table.
set_index_columns(new_index_columns: Dict[int, int]) -> None
Set the index_columns attribute. Overwrites any existing values.
A dict must be supplied. This dict should map index level to a
single 0-indexed column number. All other columns will be considered
as data columns.
set_instructions(new_instructions: Any) -> None
Set instructions attribute.
set_legend(new_legend: Optional[List[Any]], overwrite: bool = True) -> None
Set a list of legend entries to the legend attribute. Overwrites
existing legend entries by default. If overwrite is False, new entries
are appended to the legend list.
set_scope(new_scope: Any) -> None
Set the scope attribute.
set_source(new_source: Any) -> None
Set the source attribute to the specified str.
set_subtitles(new_subtitles: Optional[List[Any]], overwrite: bool = True) -> None
Set a list of subtitles to the subtitles attribute. Overwrites
existing ist of subtitles by default. If overwrite is False, new list
is appended to existing list of subtitles.
set_table(new_table: pd.DataFrame, new_index_columns: Optional[Dict[int, int]] = None, new_units: Optional[Dict[Any, Any]] = None, new_table_notes: Optional[Dict[Any, Any]] = None) -> None
Set the table, index_columns, units and table_notes attributes. Overwrites
existing values for these attributes.
set_table_name(new_table_name: str) -> None
Set the table_name attribute.
set_table_notes(new_table_notes: Optional[Dict[Any, Any]]) -> None
Adds note references to column headers.
table_notes should be in the format {column: "$$note_reference$$"}.
Column can be column name or 0-indexed column number in table.
set_title(new_title: Any) -> None
Set the title attribute.
set_units(new_units: Optional[Dict[Any, Any]]) -> None
Adds units to column headers.
Units should be in the format {column: units_text}. Column can be column name or 0-indexed column
number in table.