Skip to content

BUG: ExcelWriter not passing engine_kwargs properly for xlsxwriter #55573

Closed
@Zethtren

Description

@Zethtren

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
testbook = pd.ExcelWriter(
    "./test.xlsx", engine="xlsxwriter", engine_kwargs={"nan_inf_to_errors": True}
)

Issue Description

Pandas documentation indicates to pass the options as a dictionary. As well as it spreading said values.

Spreading confirmed here

xlsxWriter docs indicate that they would like to receive the dictionary (unspread) as the secondary argument.

Also:
I do not get any runtime errors from this but, I get a linter message from PyRight for AbstractBaseClass

 │     Cannot instantiate abstract class "ExcelWriter" Pyright (reportGeneralTypeIssues) [10, 6]
 │        "ExcelWriter.sheets" is abstract 
 │        "ExcelWriter.book" is abstract 

Presumably because of NotImplementedError? I might have to re-raise this with PyRight. Let me know on that.

Expected Behavior

Directly pass the dictionary of arguments without spreading to xlsxwriter.

Installed Versions

commit : 0f43794
python : 3.11.5.final.0
python-bits : 64
OS : Linux
OS-release : 6.5.7-arch1-1
Version : #1 SMP PREEMPT_DYNAMIC Tue, 10 Oct 2023 21:10:21 +0000
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.0.3
numpy : 1.25.2
pytz : 2023.3
dateutil : 2.8.2
setuptools : 68.1.2
pip : 23.2.1
Cython : None
pytest : 7.4.0
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.1.2
lxml.etree : None
html5lib : None
pymysql : 1.4.6
psycopg2 : None
jinja2 : 3.1.2
IPython : None
pandas_datareader: None
bs4 : 4.12.2
bottleneck : None
brotli : None
fastparquet : None
fsspec : 2023.6.0
gcsfs : None
matplotlib : 3.7.2
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : 13.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.11.2
snappy : None
sqlalchemy : 1.4.46
tables : None
tabulate : 0.9.0
xarray : None
xlrd : 2.0.1
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugClosing CandidateMay be closeable, needs more eyeballsIO Excelread_excel, to_excel

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions