Skip to content

Series.astype(str, skipna=True) vanished in the 1.0 release #31708

Closed
@languitar

Description

@languitar

Code Sample, a copy-pastable example if possible

pd.Series([None, 42]).astype(str, skipna=True)

results in TypeError: astype() got an unexpected keyword argument 'skipna'

Problem description

The provided snippet used to work before the 1.0 release. With the skipna argument, the None was preserved as a real np.nan type, instead of being converted to the string nan. The skipna argument seems to have gone in the 1.0 release and I can't find any way to restore this behavior without a custom function being passed to apply.

Expected Output

A series with [np.nan, '42']

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit : None python : 3.8.1.final.0 python-bits : 64 OS : Linux OS-release : 5.5.1-arch1-1 machine : x86_64 processor : byteorder : little LC_ALL : None LANG : en_US.utf8 LOCALE : en_US.UTF-8

pandas : 1.0.0
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 19.3
setuptools : 44.0.0
Cython : None
pytest : 5.3.5
hypothesis : None
sphinx : 2.2.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.2
html5lib : 1.0.1
pymysql : None
psycopg2 : 2.8.4 (dt dec pq3 ext lo64)
jinja2 : 2.11.1
IPython : 7.12.0
pandas_datareader: 0.8.1
bs4 : 4.8.2
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.4.2
matplotlib : 3.1.3
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.3.5
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.13
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    AstypeBugClosing CandidateMay be closeable, needs more eyeballsNeeds DiscussionRequires discussion from core team before further actionRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions