BUG?: 1.2.5 astype('bool')
converts NaNs in 'category'
columns to True
#42189
Labels
Bug
Categorical
Categorical Data Type
Dtype Conversions
Unexpected or buggy dtype conversions
Missing-data
np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
I have checked that this issue has not already been reported.
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.
Code Sample, a copy-pastable example
In 1.2.5 produces:
In 1.2.4 produces:
Problem description
At first, I thought this was a bug, but the
astype
call producingobject
dtype only started showing up in 1.2.0, so I went back and checked 1.1.5, and 1.2.5 now matches what was on 1.1.5.This makes me think that the behavior in 1.1.5 and 1.2.5 is the expected behavior, but I don't see a release note in 1.1.5 referencing this change back to the expected, so I just wanted to point this out incase it was an unknown regression/fix or a bug of some sort.
I do see that #41797 seems like a similar problem that also first showed up in 1.2.0 and was fixed in 1.2.5, so I'm wondering if they're related.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 7c48ff4
python : 3.8.2.final.0
python-bits : 64
OS : Darwin
OS-release : 19.6.0
Version : Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.2.5
numpy : 1.20.3
pytz : 2021.1
dateutil : 2.8.1
pip : 21.1.2
setuptools : 41.2.0
Cython : None
pytest : 6.0.1
hypothesis : None
sphinx : 3.2.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.18.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 2021.06.0
fastparquet : 0.5.0
gcsfs : None
matplotlib : 3.2.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 4.0.1
pyxlsb : None
s3fs : None
scipy : 1.6.3
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : 0.53.1
The text was updated successfully, but these errors were encountered: