You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
data=pd.read_csv(file, dtype={'donor':str}, index_col='donor') # dtype of the index IS NOT str# to fix:data=pd.read_csv(file, dtype={'donor': str})
data.set_index('donor', drop=True, inplace=True)
Problem description
during pd.read_csv(), when I set a dtype to one column and set the same column as index, the index dtype is lost
Expected Output
When both dtype and index_col are used with the same column, I want the index in dtype specificied in the pd.read_csv() call, i.e. in my example str
Output of pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.6.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
Code Sample, a copy-pastable example if possible
Problem description
during pd.read_csv(), when I set a dtype to one column and set the same column as index, the index dtype is lost
Expected Output
When both dtype and index_col are used with the same column, I want the index in dtype specificied in the pd.read_csv() call, i.e. in my example str
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.6.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 1.0.1
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.0
pip : 20.0.2
setuptools : 45.2.0
Cython : None
pytest : 5.0.1
hypothesis : 4.27.0
sphinx : 2.1.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.1
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.13.0
pandas_datareader: None
bs4 : 4.8.2
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.4.1
matplotlib : 3.1.3
numexpr : None
odfpy : None
openpyxl : 3.0.0
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.0.1
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.13
tables : None
tabulate : None
xarray : 0.12.3
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
numba : None
The text was updated successfully, but these errors were encountered: