table

class virtualitics_sdk.elements.table.SubTable(title='', description='', subtable=None)

Bases: object

to_json()
class virtualitics_sdk.elements.table.SubtableStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

ERROR = 'error'
PENDING = 'pending'
SUCCESS = 'success'
class virtualitics_sdk.elements.table.Table(content, downloadable=False, filters_active=False, title='', description='', show_title=True, show_description=True, cell_colors=None, text_colors=None, column_descriptions=None, data_grid=False, searchable=True, expandable=True, missing_values=False, subtables=None, notes=None, links=None, show_filter=False, max_table_rows_to_display=2500, xlsx_config=None, editable=True, max_table_row_height=300)

Bases: Element

A Table element.

Parameters:
  • content (Union[DataFrame, PandasPersistence, Dataset, Workbook]) – A DataFrame, Pandas series, or Dataset.

  • downloadable (bool) – Whether this table should be downloaded, defaults to False.

  • filters_active (bool) – Whether the filters are active on this table, defaults to False.

  • title (str) – The title of the element, defaults to ‘’.

  • description (str) – The element’s description, defaults to ‘’.

  • show_title (bool) – Whether to show the title on the page when rendered, defaults to True.

  • show_description (bool) – Whether to show the description to the page when rendered, defaults to True.

  • cell_colors (Optional[DataFrame]) – Dataframe of cell colors as hex strings Columns should exist inside source dataset, defaults to None, joined to in content dataframe by index

  • text_colors (Optional[DataFrame]) – Dataframe of text colors as hex strings Columns should exist inside source dataset, defaults to None, joined to in content dataframe by index

  • column_descriptions (Optional[Dict[str, str]]) – Descriptions of the column of the inputs. These can be set for specific columns and must not be set for every column, defaults to None.

  • data_grid (bool) – Whether to show the datagrid version of a Table with advanced features, defaults to False.

  • searchable (bool) – When in datagrid mode, toggles the ability to search table values, defaults to True.

  • expandable (bool) – Whether a datagrid table has expandable rows, defaults to True.

  • missing_values (bool) – Set to true if this table contains missing values and you want to flag this to the user.

  • subtables (Optional[Callable[[StoreInterface, dict], SubTable]]) – Function call that creates an expanded subtable. This function contains the StoreInterface and a dictionary containing the row data and returns a SubTable, defaults to None

  • notes (Optional[List[str]]) – The popover description that shows upon hovering over a particular row. Each index in the list maps to the corresponding row. Defaults to None.

  • links (Optional[List[str]]) – The link to redirect to when hovering over a particular row. Each index in the list maps to the corresponding row. Defaults to None.

  • show_filter (bool) – Whether to show the filter on the page when rendered, defaults to False.

  • max_table_rows_to_display (int) – Defaults to 2500 rows, this is the number of rows that will be sent to the frontend, however the entire table is downloadable from the frontend regardless of this limit. Browsers with more resources may be able to handle much larger limits than this default value.

  • xlsx_config (Dict) – dictionary of configurable parameters for tables that are backed by an xlsx object

  • editable (bool) – should this table be editable by the user from the frontend. This defaults to true.

  • max_table_row_height (int) – The maximum height of the table rows. Defaults to 300 characters.

Raises:

NotImplementedError – When table is created with invalid type.

get_df(content, params)
Return type:

DataFrame

get_dtypes(_df)
Return type:

Dict

classmethod json_to_pandas_table_content(content)
Return type:

Tuple[DataFrame, DataFrame, DataFrame]

save(link, is_ssf=False)

Save a table serialization into a Link.

Parameters:

link (Link) – The link to save the element to.

set_content(content)

Validate and set content (python best practice is to set instance attributes in constructor).

Parameters:

kwargs – new content for the Element.

set_params(params)

Validate and set params (python best practice is to set instance attributes in constructor).

Parameters:

kwargs – new params for the Element.

to_json()

Convert the element to a JSON.

Return type:

dict

Returns:

A JSON dictionary of the element.

classmethod update_overwrite_table_data(updated_content, meta_data, original_data, user)
virtualitics_sdk.elements.table.get_text_and_cell_colors(meta_data, user=None)
Return type:

Tuple[DataFrame, DataFrame]

virtualitics_sdk.elements.table.merge_data_frame_to_openpyxl(_df, _workbook, xlsx_config)

Take a dataframe with the same layout as an Excel workbook and merge the changes into the workbook object. This allows you to change the values of an existing workbook and preserve all the formatting, functions, etc. from the source excel object so that it can be exported. This is kind of like a Paste Values operation where the dataframe value only are pasted into the Excel _worksheet

Parameters:
  • _df (DataFrame) – a dataframe representing the modified table with the values to override the existing workbook values

  • _workbook (Workbook) – the source openpyxl Workbook object

  • xlsx_config (Dict) – a configuration dictionary with different parameters relevant to parsing the workbook into a predict table element

Returns: