Skip to content
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 and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPR: Timedelta.delta #46476

Merged
merged 2 commits into from
Mar 23, 2022
Merged

DEPR: Timedelta.delta #46476

merged 2 commits into from
Mar 23, 2022

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

It's redundant and promises to become confusing once we have non-nano td64.

@@ -1014,6 +1014,12 @@ cdef class _Timedelta(timedelta):
>>> td.delta
42
"""
# Deprecated GH#46476
warnings.warn(
"Timedelta.delta is deprecated and will be removed in a future version.",
Copy link
Member

Choose a reason for hiding this comment

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

Probably good to mention the alternative in the message?

Copy link
Member Author

Choose a reason for hiding this comment

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

i'm not sure there is a good alternative. since the meaning of .value may change as we get non-nano working

Copy link
Contributor

Choose a reason for hiding this comment

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

In [96]: td / pd.Timedelta('1ns')
Out[96]: 123456546.0

In [97]: td / pd.Timedelta('1s')
Out[97]: 0.123456546

you can say the alt is to convert a float like this which puts it in the specified units.

Copy link
Member Author

Choose a reason for hiding this comment

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

well neither of those is the same behavior they're getting now.

Telling the user how to "keep the same behavior" really depends on what they are trying to do:

  1. using .value directly is good if they just want to get at the guts of the object
  2. or .view("i8") if for some reason they want the same thing but slower
  3. if they really care about getting a number of nanoseconds then they need obj.to_timedelta64("ns").view("i8") (which risks overflowing in a non-nano world)

I think we deprecate like this and wait to see if anyone complains.

@mroeschke mroeschke added the Deprecate Functionality to remove in pandas label Mar 22, 2022
@mroeschke mroeschke added this to the 1.5 milestone Mar 22, 2022
@jreback jreback added the Timedelta Timedelta data type label Mar 22, 2022
@jreback jreback merged commit 0aea13b into pandas-dev:main Mar 23, 2022
@jbrockmendel jbrockmendel deleted the depr-delta branch March 23, 2022 01:06
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants