Skip to content

datetime64 chokes on sub-nanosecond input string #5452

Open

Description

@dmopalmer

When a datetime64 is created from a string with more than 9 decimal places in the second, the result is corrupt.

>>> numpy.datetime64('2015-01-01T01:00:00.000000000-0700')
numpy.datetime64('2015-01-01T01:00:00.000000000-0700')
>>> numpy.datetime64('2015-01-01T01:00:00.0000000000-0700')
numpy.datetime64('1969-12-28T12:38:26.324364525568Z')

The first instance with 9 decimal places in the seconds is correct. The second, with 10 decimal places is incorrect.

Versions: numpy 1.9.1; OSX 10.9.5; Python 2.7.9;
Python and numpy installed using macports.
Replicated on RHEL/Python 3.2.5/numpy 1.8.0

Activity

  1. shoyer commented on Jan 19, 2015

    @shoyer
    Member

    It's not possible to this represent value with a sub-nanosecond datetime64 object: http://docs.scipy.org/doc/numpy/reference/arrays.datetime.html#datetime-units

    So the real issue is that datetime64 wraps input silently instead of raising an error.

    This is only one of a long list of datetime64 issues that make the type difficult to use reliably.

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