Skip to content

convert_object not converting to NaN #4119

Closed
@hayd

Description

@hayd

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions