table#

class predict_backend.page.elements.table.SubTable(title='', description='', subtable=None)#

Bases: object

to_json()#
class predict_backend.page.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 predict_backend.page.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)#

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. :param advanced_tooltip: The function to call that creates an expanded subtbales. This functions contains the StoreInterface and

    a pd.Series 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.

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]

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)#
predict_backend.page.elements.table.get_text_and_cell_colors(meta_data, user=None)#
Return type:

Tuple[DataFrame, DataFrame]

predict_backend.page.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: