Skip to content

BUG: Silent overflow when casting large date strings to M8[ns] #9956

Open

Description

@jcrist

When converting date strings that exceed the maximum value for their precision to datetime64s, the resulting values silently overflow instead of erroring/warning.

Following the overflow warnings given for other types, I would have expected a warning or error here. Tested as far back as 1.11, still has the same issue.

In [1]: import numpy as np

In [2]: x = np.array(['4998-01-01 00:00:00'], dtype='O')

In [3]: x.astype('M8[ns]')  # overflows
Out[3]: array(['2075-03-26T02:07:11.452241920'], dtype='datetime64[ns]')

In [4]: x.astype('M8[ms]')  # no overflow
Out[4]: array(['4998-01-01T00:00:00.000'], dtype='datetime64[ms]')

In [5]: np.__version__
Out[5]: '1.13.3'

Activity

  1. changed the title [-]Silent overflow when casting large date strings to `M8[ns]`[/-] [+]BUG: Silent overflow when casting large date strings to `M8[ns]`[/+] on Nov 5, 2017
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