valpas.io.export_xlsx#

valpas.io.export_xlsx(filepath, dfs, sheets, overwrite=False)#

Helper function to export computed DataFrame(s) to an Excel file

Parameters:
  • filepath (str | PathLike | Path) – Path to *.xlsx file that should be used for the export of data

  • dfs (pandas.DataFrame | list[pandas.DataFrame]) – Either a single pandas.DataFrame object or a list of objects. If a list is passed to the function, sheets must also be a list and the number of elements in both must be identical.

  • sheets (str | list[str]) – Either a single String or a list of Strings containing the names that the sheets should be stored as in the *.xlsx file. If a list is passed to the function, dfs also needs to be a list and both need to contain the same number of elements.

  • overwrite (bool, default=False) – Indicates if sheets should be overwritten if they already exist in the *.xlsx file that is passed to the function.

Return type:

None

Raises:
  • TypeError – If the passed filepath is not the correct type

  • TypeError – If dfs or sheets is not the correct type or they don’t match in type (e.g. type(dfs)==list & type(sheets)==str)

  • ValueError – If both dfs and sheets are of type list, but the don’t hold the same number of items.