-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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: pandas.read_excel() with dtype=object is broken in pandas 2.1.1 #55489
Comments
Can you share the excel file directly or a way to generate the excel file, e.g. using |
Thanks for the report, is specifying |
cc @WillAyd |
This was added in 588e29d. I think this is behaving as expected.
There is no inference done - including inferring that the value is an integer! So we must store them as Python objects, but they are indeed Python ints. I think the doc could be clarified better - explicitly mentioning that the result will be object dtype. |
Hi, could I work on this, would you prefer to change the docs maybe perhaps pointing me in the right direction |
Certainly! See the contributor guide. For this particular issue, we're looking to better explain that specifying |
perfect ill get that done :) |
Hi, @rhshadrach ! As I saw that the issue was still open, I decided to fix it considering the previous attempts , I hope that's OK - let me know if you have any questions or clarifications. Thanks! :) |
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
Create an excel file nammed
xl_file.xlsx
, with one worksheet namedSheet1
as following:Then save it and run this code in the directory where you created the excel file :
Issue Description
The method
pandas.read_excel()
with argumentdtypes=object
does not prevent pandas from converting data types, as described on the offical documentation pageExpected Behavior
when we use the method
pandas.read_excel()
with argumentdtypes=object
, on an Excel workbook which contains int values, the dtypes of this columns should beint64
Installed Versions
pandas : 2.1.1
numpy : 1.24.2
pytz : 2023.3
dateutil : 2.8.2
setuptools : 65.5.0
pip : 23.2.1
Cython : None
pytest : 7.3.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.1.7
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : None
pandas_datareader : None
bs4 : None
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: