Skip to content

Series apply() and map() may produce a Series with different dtype than the original #1414

Closed
@lbeltrame

Description

@lbeltrame

I'm unsure if it's by design or not, so I'm leaving this here.

In [84]: original = pandas.Series([1,2,3, np.nan], dtype="object")

In [85]: def convert(value):
    return np.nan if pandas.isnull(value) else int(value)
   ....: 

In [86]: original.apply(convert).dtype
Out[86]: dtype('float64')

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions