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
s = pd.Series(dtype="int", index=[0])
print(s.dtype) # float?!
Issue Description
When creating a series with dtype int while also specifying the index (without data), the resulting dtype is float.
Expected Behavior
The dtype should be int and the value should be 0 instead of NaN. This issue seems to have been introduced in version 1.4.0, 1.3.5 still worked as expected.
Installed Versions
INSTALLED VERSIONS
commit : 06d2301
python : 3.8.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.10.76-linuxkit
Version : #1 SMP Mon Nov 8 10:21:19 UTC 2021
machine : x86_64
processor :
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.4.1
numpy : 1.19.5
pytz : 2021.3
dateutil : 2.8.1
pip : 21.2.4
setuptools : 58.1.0
Cython : 0.29.24
pytest : 6.2.5
hypothesis : 5.23.7
sphinx : 2.2.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.7.1
html5lib : None
pymysql : None
psycopg2 : 2.8.6
jinja2 : 2.11.3
IPython : 8.0.0
pandas_datareader: None
bs4 : None
bottleneck : 1.3.2
fastparquet : None
fsspec : 2022.01.0
gcsfs : None
matplotlib : 3.3.4
numba : 0.53.1
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 5.0.0.2
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.5.2
sqlalchemy : 1.3.24
tables : None
tabulate : 0.8.7
xarray : None
xlrd : 1.2.0
xlwt : None
zstandard : 0.14.0