BUG: astype from categorical to np.int32 conversion returns np.int64 in pandas 1.2.0 and 1.2.0 #39402
Labels
Bug
Categorical
Categorical Data Type
Dtype Conversions
Unexpected or buggy dtype conversions
Regression
Functionality that used to work in a prior pandas version
Milestone
[x ] I have checked that this issue has not already been reported.
[x ] I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Problem description
[this should explain why the current behaviour is a problem and why the expected output is a better solution]
in pandas 1.1.5 astype correctly returning np.int32 as the column1 dtype.
This is expected as we are trying to convert this categorical col into np.int32.
Now it returns np.int64 in pandas 1.2.x
Expected Output
no assertion error
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 3e89b4c
python : 3.8.5.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.17763
machine : AMD64
processor : Intel64 Family 6 Model 79 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : English_United States.1252
pandas : 1.2.0
numpy : 1.18.5
pytz : 2020.5
dateutil : 2.8.1
pip : 20.1.1
setuptools : 51.3.3.post20210118
Cython : None
pytest : 5.4.3
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.3.7
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.19.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 2.0.0
pyxlsb : None
s3fs : None
scipy : 1.6.0
sqlalchemy : 1.3.22
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
[paste the output of
pd.show_versions()
here leaving a blank line after the details tag]pd.show_versions()
The text was updated successfully, but these errors were encountered: