Skip to content

astype conversion to str converts NaN object to literal nan string #25716

@joetl

Description

@joetl
# Your code here
import pandas as pd
from numpy import nan
df = pd.DataFrame([{'sample': nan }])
df.iloc[0].sample
df.astype('str').iloc[0].sample

Problem description

When converting any datatype column to string using astype('str') null values (NaN object) is converted to literal nan string
Instead of remaining as null object value

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions