TimedeltaIndex + Timestamp -> no overflow error #14068

Closed
mathause opened this Issue Aug 22, 2016 · 3 comments

Comments

Projects
None yet
3 participants

mathause commented Aug 22, 2016 edited

When adding a TimedeltaIndex and a Timestamp this overflows instead of raising (pydata/xarray#975).

import pandas as pd

# overflow error (correct)
pd.to_timedelta(106580, 'D') + pd.Timestamp('2000')
# no overflow error (?)
pd.to_timedelta([106580], 'D') + pd.Timestamp('2000')

output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.12.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-24-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.1
nose: None
pip: 8.1.2
setuptools: 25.1.6
Cython: None
numpy: 1.11.1
scipy: None
statsmodels: None
xarray: 0.7.2-73-g584e703
IPython: 5.1.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: 1.1.0
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None

edit: 'D' as unit

mathause referenced this issue in pydata/xarray Aug 22, 2016

Closed

invalid timestamps in the future #975

Member

shoyer commented Aug 22, 2016

@mathause your code is missing the value of delta

thanks & apologies, 'twas already late - I edited my comment above

@mathause mathause added a commit to mathause/xarray that referenced this issue Aug 23, 2016

@mathause mathause fix datetime issues
- pretty print when date is out of bounds
- decode_cf_datetime when first date is in bound but later dates are not
- work around pandas Overflow error (pandas-dev/pandas#14068)
5ce7b20

mathause referenced this issue in pydata/xarray Aug 23, 2016

Merged

fix datetime issues #984

Contributor

jreback commented Aug 24, 2016

xref pydata#12534

yeah this is detectable I think. you can just check the sign of the result. e.g. (should be the same as the sign of the timedelta), as numpy doesn't raise on overflow :<

In [63]: pd.to_timedelta([106580], 'D').values + pd.Timestamp('2000').value
Out[63]: array([-8291547273709551616], dtype='timedelta64[ns]')

jreback added this to the Next Major Release milestone Aug 24, 2016

jreback added the Bug label Aug 24, 2016

@mathause mathause added a commit to mathause/xarray that referenced this issue Aug 25, 2016

@mathause mathause fix datetime issues
- pretty print when date is out of bounds
- decode_cf_datetime when first date is in bound but later dates are not
- work around pandas Overflow error (pandas-dev/pandas#14068)
e412bc5

@shoyer shoyer added a commit to pydata/xarray that referenced this issue Aug 25, 2016

@mathause @shoyer mathause + shoyer fix datetime issues (#984)
* fix datetime issues

- pretty print when date is out of bounds
- decode_cf_datetime when first date is in bound but later dates are not
- work around pandas Overflow error (pandas-dev/pandas#14068)

* correct indendation

* revise fix datetime issues

* update whats-new
6cf5d0c

@gfyoung gfyoung added a commit to gfyoung/pandas that referenced this issue Sep 27, 2016

@gfyoung gfyoung BUG: Check for overflow in TimedeltaIndex addition.
Closes gh-14068.
77effde

@jreback jreback modified the milestone: 0.19.0, Next Major Release Sep 27, 2016

jreback closed this in 977b384 Sep 27, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment