Skip to content

API: replace casting dtype instead of converting NA value when replacing missing value with another missing value #49421

@phofl

Description

@phofl

See discussion in #48234

when doing

pd.Series([1.0, np.nan]).replace(np.nan, value=None)

this casts to object, which is inconsistent with what other methods do.

The non special logic would look like:

def replace(self, old, new):
    if is_valid_na_for_dtype(new, self.dtype):
        new = self. _standardize_fill_value(new)

cc @jbrockmendel @mroeschke

Metadata

Metadata

Assignees

No one assigned

    Labels

    API - ConsistencyInternal Consistency of API/BehaviorClosing CandidateMay be closeable, needs more eyeballsDtype ConversionsUnexpected or buggy dtype conversionsreplacereplace method

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions