bolster.utils.io ================ .. py:module:: bolster.utils.io .. autoapi-nested-parse:: File I/O helpers. Provides thin wrappers around :mod:`pandas` I/O for common tasks, such as writing multiple DataFrames to separate sheets of a single Excel workbook. .. rubric:: Example >>> import pandas as pd >>> from bolster.utils.io import save_xls >>> import tempfile, os >>> df1 = pd.DataFrame({"a": [1, 2]}) >>> df2 = pd.DataFrame({"b": [3, 4]}) >>> with tempfile.NamedTemporaryFile(suffix=".xlsx", delete=False) as f: ... tmp = f.name >>> save_xls({"Sheet1": df1, "Sheet2": df2}, tmp) >>> os.remove(tmp) Functions --------- .. autoapisummary:: bolster.utils.io.save_xls Module Contents --------------- .. py:function:: save_xls(dict_df, path) Write a mapping of sheet-name → DataFrame to a multi-sheet Excel file. :param dict_df: Mapping of sheet names to DataFrames. Each key becomes a worksheet name; each value is written to that sheet. :param path: File path (``str``) or writable binary file-like object for the output ``.xlsx`` workbook. .. rubric:: Example >>> import pandas as pd, tempfile, os >>> df = pd.DataFrame({"x": [10, 20]}) >>> with tempfile.NamedTemporaryFile(suffix=".xlsx", delete=False) as f: ... tmp = f.name >>> save_xls({"Results": df}, tmp) >>> os.remove(tmp)