BUG: read_csv not applying dtype to index col when dtype is globally specified #45801
Open
2 of 3 tasks
Labels
Bug
IO CSV
read_csv, to_csv
Needs Discussion
Requires discussion from core team before further action
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
This is separated from #44632. More discussions on #9435. In version 1.4.0 it does fix the case when dtype is defined for a column specifically:
works. But not when you specify dtype globally.
Expected Behavior
I expect by specifying
index_col=0, dtype=str
which requires all columns bestr
, then the first column is also a str and is used as index as well. With current version of pandas I am not sure what's the alternative implementation for my expected behavior.Installed Versions
INSTALLED VERSIONS
commit : bb1f651
python : 3.8.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-39-generic
Version : #43-Ubuntu SMP Fri Jun 19 10:28:31 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.4.0
numpy : 1.19.5
pytz : 2020.5
dateutil : 2.8.1
pip : 20.2.4
setuptools : 50.3.1.post20201107
Cython : None
pytest : 6.2.2
hypothesis : None
sphinx : 4.3.1
blosc : None
feather : 0.4.1
xlsxwriter : None
lxml.etree : 4.6.2
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.19.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : None
fastparquet : None
fsspec : 0.8.5
gcsfs : None
matplotlib : 3.3.4
numba : None
numexpr : 2.7.2
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : 0.17.1
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.6.0
sqlalchemy : 1.3.22
tables : None
tabulate : 0.8.7
xarray : 0.16.2
xlrd : 2.0.1
xlwt : None
zstandard : 0.15.1
The text was updated successfully, but these errors were encountered: