gsolve.core.excel_io.write_excel_worksheet

gsolve.core.excel_io.write_excel_worksheet#

gsolve.core.excel_io.write_excel_worksheet(df, excel_file, sheet_name, if_workbook_exists='error', if_sheet_exists='error', **kwargs)[source]#

Write DataFrame to excel workbook excel_file in the worksheet sheet_name.

Parameters:
dfDataFrame

The DataFrame to write to the excel file.

excel_filestr or PathLike

The path to the excel file.

sheet_namestr

The name of the worksheet to write to.

if_workbook_exists: {“error”, “replace”, “append”}, default “error”

Behaviour if excel_file already exists. - “error”: raise a ValueError. - “replace”: replace the existing file. - “append”: append to the existing file.

if_sheet_exists: {“error”, “replace”, “new”}, default “error”

Behaviour if the sheet_name already exists in excel_file (append mode only) - “error”: raise a ValueError. - “replace”: replace the existing worksheet. - “new”: create a new worksheet with different name

kwargs

Additional arguments passed to pandas.DataFrame.to_excel method.

See also

pandas.DataFrame.to_excel

The underlying function used to write the DataFrame to the excel file.

pandas.ExcelWriter