Skip to content

date_range produces wrong values when overflowing #14187

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

In the following case, you now get a RuntimeWarning. But shouldn't we rather error on this?

In [23]: pd.date_range('1/1/2000', periods=100000, freq='D')
/home/joris/scipy/pandas/pandas/tseries/index.py:1944: RuntimeWarning: overflow encountered in long_scalars
  e = b + np.int64(periods) * stride
/home/joris/scipy/pandas/pandas/tseries/index.py:1954: RuntimeWarning: overflow encountered in long_scalars
  data = np.arange(b, e, stride, dtype=np.int64)
Out[23]: 
DatetimeIndex([          '2000-01-01 00:00:00',
                         '2000-01-02 00:00:00',
                         '2000-01-03 00:00:00',
                         '2000-01-04 00:00:00',
                         '2000-01-05 00:00:00',
                         '2000-01-06 00:00:00',
                         '2000-01-07 00:00:00',
                         '2000-01-08 00:00:00',
                         '2000-01-09 00:00:00',
                         '2000-01-10 00:00:00',
               ...
               '1689-03-17 00:25:26.290448384',
               '1689-03-18 00:25:26.290448384',
               '1689-03-19 00:25:26.290448384',
               '1689-03-20 00:25:26.290448384',
               '1689-03-21 00:25:26.290448384',
               '1689-03-22 00:25:26.290448384',
               '1689-03-23 00:25:26.290448384',
               '1689-03-24 00:25:26.290448384',
               '1689-03-25 00:25:26.290448384',
               '1689-03-26 00:25:26.290448384'],
              dtype='datetime64[ns]', length=100000, freq='D')

In [24]: pd.__version__
Out[24]: '0.19.0rc1+2.gd8cd33b'

In [25]: np.__version__
Out[25]: '1.11.1'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas objects compatability with Numpy or Python functionsDatetimeDatetime data dtypeError ReportingIncorrect or improved errors from pandas

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions