Skip to content
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

convert_object not converting to NaN #4119

Closed
hayd opened this issue Jul 3, 2013 · 0 comments · Fixed by #4120

Comments

@hayd
Copy link
Contributor

commented Jul 3, 2013

docstring seem to suggest that this ought to convert to NaN:

In [10]: s = pd.Series([1, 'na', 3 ,4])

In [11]: s.convert_objects(convert_numeric=True)
Out[11]:
0     1
1    na
2     3
3     4
dtype: object

Docstring:

convert_numeric : boolean, default True
    if True attempt to coerce to numbers (including strings),
    non-convertibles get NaN

However, does work if the non-strings are stringified first

In [142]: pd.Series([1, 'na', 3 ,4]).astype(str).convert_objects(convert_numeric=True)
Out[142]: 
0     1
1   NaN
2     3
3     4
dtype: float64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.