Thanks to visit codestin.com
Credit goes to github.com

Skip to content

NaN should become NaT when assigned to datetime64 #8780

@gerritholl

Description

@gerritholl

When an array has dtype datetime64, setting to NaN should convert to NaT. Currently, it fails with ValueError:

In [49]: x = numpy.zeros(dtype="M8[s]", shape=5)
In [51]: x[2] = numpy.nan
…
ValueError: Could not convert object to NumPy datetime

The instruction = numpy.nan is not ambiguous in any way. When setting all the values of a structured dtype with floats and datetime types to nan it is much easier if we don't need to separately handle the case for nat.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions