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 io
import numpy as np
import pandas as pd
data = io.StringIO("345.5 519.5 0\n519.5 726.5 1\n")
df = pd.read_csv(
data,
sep=r"\s+",
header=None,
names=["start", "stop", "bin_id"],
dtype={"start": np.float32, "stop": np.float32, "bin_id": np.uint32},
index_col="bin_id"
)
print(df.index.dtype)
Issue Description
df.index.dtype
is int64
with pandas 3.0.0.dev0+1132.ga5e812d86d
, although the dtype
parameter already sets it to np.uint32
. The issue is similar to an old issue #9435.
Expected Behavior
Pandas 2.x correctly returns uint32
, which is the expected behavior.
Installed Versions
pandas : 3.0.0.dev0+1132.ga5e812d86d
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 70.0.0
pip : 24.0
Cython : None
pytest : 8.2.1
hypothesis : None
sphinx : 7.3.7
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.4
IPython : 8.25.0.dev
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
bottleneck : None
fastparquet : None
fsspec : 2024.5.0
gcsfs : None
matplotlib : 3.10.0.dev202+gd901275d7c
numba : None
numexpr : None
odfpy : None
openpyxl : None
pyarrow : 16.1.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : 0.9.0
xarray : 2024.5.1.dev6+g12123be8
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None
</details>