8000 Inconsistent and incorrect datetime64 string representations when in structured array · Issue #5692 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
Inconsistent and incorrect datetime64 string representations when in structured array #5692
Closed
@gerritholl

Description

@gerritholl

datetime64 string representations are inconsistent when in structured arrays. When the value should be NaT, they are shows as None inside a structured array. The showing of timezones is also inconsistent, as the code snippet below shows.

In [196]: A = numpy.zeros(shape=10, dtype=[("A", "M8[s]")])

In [197]: A[5:].fill(numpy.nan)

In [198]: A
Out[198]: 
array([(datetime.datetime(1970, 1, 1, 0, 0),),
       (datetime.datetime(1970, 1, 1, 0, 0),),
       (datetime.datetime(1970, 1, 1, 0, 0),),
       (datetime.datetime(1970, 1, 1, 0, 0),),
       (datetime.datetime(1970, 1, 1, 0, 0),), (None,), (None,), (None,),
       (None,), (None,)], 
      dtype=[('A', '<M8[s]')])

In [199]: A["A"]
Out[199]: 
array(['1969-12-31T19:00:00-0500', '1969-12-31T19:00:00-0500',
       '1969-12-31T19:00:00-0500', '1969-12-31T19:00:00-0500',
       '1969-12-31T19:00:00-0500', 'NaT', 'NaT', 'NaT', 'NaT', 'NaT'], dtype='datetime64[s]')

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

      0