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

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


Copy link

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)
0     1
1    na
2     3
3     4
dtype: object


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)
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
None yet
1 participant
You can’t perform that action at this time.