BUG: astype("str")
converts NA values to strings
#44156
Labels
Astype
Bug
Dtype Conversions
Unexpected or buggy dtype conversions
Missing-data
np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
NA - MaskedArrays
Related to pd.NA and nullable extension arrays
Strings
String extension data type and string data
Uh oh!
There was an error while loading. Please reload this page.
Reproducible Example
Issue Description
NA/null values are converted to their string representation when doing
.astype("str")
, which seems like odd/undesirable behaviour.Expected Behavior
Installed Versions
INSTALLED VERSIONS
commit : 9b2bb73
python : 3.9.7.final.0
python-bits : 64
OS : Darwin
OS-release : 20.6.0
Version : Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 1.4.0.dev0+952.g9b2bb732f0
numpy : 1.21.3
pytz : 2021.3
dateutil : 2.8.2
pip : 21.3
setuptools : 58.2.0
Cython : 0.29.24
pytest : 6.2.5
hypothesis : 6.23.4
sphinx : 4.2.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.3
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.0.2
IPython : None
pandas_datareader: None
bs4 : 4.10.0
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : 5.0.0
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : 0.8.9
xarray : None
xlrd : 2.0.1
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: