Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
joetl opened this issue Mar 13, 2019 · 1 comment
Closed

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

joetl opened this issue Mar 13, 2019 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request

Comments

@joetl
Copy link

joetl commented Mar 13, 2019

# 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

@TomAugspurger
Copy link
Contributor

Dupe of #25353, and probably others.

@TomAugspurger TomAugspurger added the Duplicate Report Duplicate issue or pull request label Mar 13, 2019
@TomAugspurger TomAugspurger added this to the No action milestone Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants