Skip to content

Inconsistent and incorrect datetime64 string representations when in structured array #5692

Closed

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]')

Activity

  1. added a commit that references this issue on Oct 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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