Description
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
path = "~/Downloads/test-from-gsheets.xlsx"
pd.read_excel(path)
Issue Description
It seems like Pandas behaves differently with Excel files downloaded from Google Sheets than with those created in Excel. Namely, with files from Google Sheets, I get .0
decimal points for columns with mixed data types (which does not happen in regular Excel files).
To reproduce: Create a new spreadsheet file in Google Drive and download as Excel. Can be as simple as one column, as long as it has numeric and string-like values:
Test |
---|
ABC123 |
234 |
When reading this file with pd.read_excel
, you get the following output (with the added .0
in the string):
Test |
---|
ABC123 |
234.0 |
Funnily enough, when I create the same file directly in Excel, I don't get the added .0
and it works fine. I was even able to fix the behaviour by opening the downloaded file in Excel and saving it again.
test-from-local.xlsx
test-from-gsheet.xlsx
Expected Behavior
Mixed type columns are read as object
type, without trailing .0
, independent of whether the Excel file was created in Excel or Google Sheets.
Installed Versions
INSTALLED VERSIONS
commit : 4bfe3d0
python : 3.9.5.final.0
python-bits : 64
OS : Darwin
OS-release : 21.4.0
Version : Darwin Kernel Version 21.4.0: Mon Feb 21 20:36:53 PST 2022; root:xnu-8020.101.4~2/RELEASE_ARM64_T8101
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 1.4.2
numpy : 1.22.3
pytz : 2022.1
dateutil : 2.8.2
pip : 22.0.4
setuptools : 52.0.0.post20210125
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
brotli :
fastparquet : None
fsspec : None
gcsfs : None
markupsafe : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.9
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