histopath_bim_des.excel module

Functions for reading Excel data

histopath_bim_des.excel.get_name(wbook: Workbook, name: str) int | float | str | datetime | list[list[int | float | str | datetime]][source]

Read an Excel named range as a single value or NumPy array. Arrays are flattened if possible.

Parameters:
  • wbook – The workbook object.

  • name – Name of the Excel range to read.

Returns: A single value, or a nested list containing the named range’s values.

histopath_bim_des.excel.get_table(wbook: Workbook, sheet_name: str, name: str) list[list[int | float | str | datetime]][source]

Reads an Excel table as a nested list.

Parameters:
  • wbook – The workbook object.

  • sheet_name – Name of the Excel worksheet containing the table.

  • name – Name of the Excel table to read.

Returns: A nested list containing the named range’s values.

histopath_bim_des.excel.remove_table_filters(table: Table, ws: Worksheet) None[source]

Remove filters from an Excel table.

Parameters:
  • table – The table to alter.

  • ws – The worksheet in which the table is to be inserted.

histopath_bim_des.excel.write_table(df: DataFrame, path: PathLike, sheet_name: str, name: str) None[source]

Writes a pandas DataFrame to an Excel table in a new worksheet, replacing the existing worksheet if found. Note that the index is not used; use df.reset_index(drop=False, names=’idx’) to include the DataFrame index.

Parameters:
  • df – The DataFrame to write.

  • path – The filepath of the workbook to write to.

  • sheet_name – The name of the worksheet to write to.

  • name – The name of the Excel table to create.