-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Dataframe.to_excel treats decimal.Decimal as string instead of numeric type, the data in the Excel cell is formatted as a string, not a number #49598
Comments
Hi, I would like to resolve this issue. |
Investigations welcome, but the other issue indicates that openpyxl can not handle decimal. |
For openpyxl, decimal should be supported from version 1.7.0 (2013-10-31) https://foss.heptapod.net/openpyxl/openpyxl/-/blob/branch/3.0/doc/changes.rst For xlsxwriter, decimal should be supported from version 0.3.8 (August 23 2013) https://xlsxwriter.readthedocs.io/changes.html I found out both by quickly looking at the change log, needs to be confirmed. But it seems like an optimistic start. @alexanderwertman3 Do you have time to investigate in more detail the compatibility with openpyxl/xlsxwriter and, eventually, propose change in code? Otherwise, I can have a look in couple of weeks. Thanks |
@rspocz, I will begin investigating this week |
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
Issue Description
The code writes value to float.xlsx as number, but it is written as string in decimal.xlsx.
I identified that in the condition here
pandas/pandas/io/excel/_base.py
Line 1367 in d56f6e2
This same issue was already raised, but it was closed with no solution (by error?) #26277
Expected Behavior
Values in both dataframes should be written to excel as number.
Installed Versions
INSTALLED VERSIONS
commit : 91111fd
python : 3.9.13.final.0
python-bits : 64
OS : Linux
OS-release : 6.0.5-200.fc36.x86_64
Version : #1 SMP PREEMPT_DYNAMIC Wed Oct 26 15:55:21 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 1.5.1
numpy : 1.23.4
pytz : 2022.6
dateutil : 2.8.2
setuptools : 65.5.1
pip : 22.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None
The text was updated successfully, but these errors were encountered: