BUG: pd.Timedelta(big_int, unit=W) silent overflow by jbrockmendel · Pull Request #47268 · pandas-dev/pandas (original) (raw)

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation5 Commits4 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

jbrockmendel

@jbrockmendel

@jbrockmendel

mroeschke

@@ -732,6 +732,7 @@ Timedelta
^^^^^^^^^
- Bug in :func:`astype_nansafe` astype("timedelta64[ns]") fails when np.nan is included (:issue:`45798`)
- Bug in constructing a :class:`Timedelta` with a ``np.timedelta64`` object and a ``unit`` sometimes silently overflowing and returning incorrect results instead of raising ``OutOfBoundsTimedelta`` (:issue:`46827`)
- Bug in constructing a :class:`Timedelta` from a large integer or float with ``unit="W"`` silently overflowing and returning incorrect results instead of raising ``OutOfBoundsTimedelta`` (:issue:`47268`)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a note in the Other API Changes section mentioning that various timstamp/timedelta constructors that would overflow now raise a OutOfBoundsTimedelta/OutOfBoundsTimestamp instead of an OverflowError (they appear to be based off of different subclasses).

Should hopefully be a catchall for all these improvements you've been making

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, updated

@jbrockmendel

@jbrockmendel

mroeschke

@mroeschke

yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request

Jul 13, 2022

@jbrockmendel @yehoshuadimarsky

@behrenhoff

According to the release notes of pandas 1.5.0

Operations with Timestamp or Timedelta that would previously raise OverflowError instead raise OutOfBoundsDatetime or OutOfBoundsTimedelta where appropriate (GH47268)

However, pd.Timedelta(seconds=60) / 1e-9 still raises an OverflowError. Is that intended? From the changelog, it seems this should return a OutOfBoundsTimedelta instead.

@jbrockmendel

still raises an OverflowError. Is that intended

No. PR to fix cases we missed would be welcome.

@qc00 qc00 mentioned this pull request

Mar 14, 2023