Skip to content

BUG: Series inconsistent with overflow errors in Timedelta calcs #43178

Open
@venaturum

Description

@venaturum
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

>>> x = pd.Series([pd.Timedelta(100000, "days"), pd.Timedelta(100000, "days")])

# Results in ValueError
>>> x.sum()

# Results in OverflowError
>>> pd.Timedelta(100000, "days")*2

# Results in OverflowError
>>> x + x

# Permits overflow
>>> x*2
0   -13504 days +00:25:26.290448384
1   -13504 days +00:25:26.290448384
dtype: timedelta64[ns]

Problem description

It would seem that pandas.Series calcs with Timedeltas are inconsistent in raising overflow errors, or not.
The exact error is also inconsistent (OverflowError vs ValueError).

Expected Output

Ideally x*2 in above example raises an error, and all overflow related errors are of type OverflowError.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 5f648bf
python : 3.7.5.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None

pandas : 1.3.2
numpy : 1.21.2
pytz : 2021.1
dateutil : 2.8.2
pip : 19.2.3
setuptools : 41.2.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugError ReportingIncorrect or improved errors from pandasNumeric OperationsArithmetic, Comparison, and Logical operationsTimedeltaTimedelta data typeUpstream issueIssue related to pandas dependency

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions