Skip to content

DEPR: Timedelta with passed unit M, Y #16344

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

Closed
jorisvandenbossche opened this issue May 12, 2017 · 1 comment · Fixed by #23264
Closed

DEPR: Timedelta with passed unit M, Y #16344

jorisvandenbossche opened this issue May 12, 2017 · 1 comment · Fixed by #23264
Labels
Deprecate Functionality to remove in pandas Timedelta Timedelta data type
Milestone

Comments

@jorisvandenbossche
Copy link
Member

In [7]: pd.Timedelta(1, unit='Y')
Out[7]: Timedelta('365 days 05:49:12')

In [8]: pd.Timedelta(1, unit='M')
Out[8]: Timedelta('30 days 10:29:06')

The above does not make much sense, so lets deprecate this (similar for to_timedelta).

For the case where those unit abbreviations are used in a string, Y already raises, while M is actually interpreted as minutes:

ValueError: invalid abbreviation: Y

In [13]: pd.to_timedelta('1M')
Out[13]: Timedelta('0 days 00:01:00')

xref #16335, #12691 and #14024

@jorisvandenbossche jorisvandenbossche changed the title DEPR: Timedelta with passed M, Y DEPR: Timedelta with passed unit M, Y May 12, 2017
@jorisvandenbossche jorisvandenbossche added Deprecate Functionality to remove in pandas Timedelta Timedelta data type labels May 12, 2017
@jorisvandenbossche jorisvandenbossche added this to the Next Major Release milestone May 12, 2017
@jorisvandenbossche
Copy link
Member Author

One question is whether we should also deprecate 'W' for week (see #14024 (comment)).

Given that this can be easily represented as 7 days, it would be easier/clearer to just have 'D' as the highest allowed unit.
On the other hand, 'W' currently gives a sensible output (as opposed to M/Y), so less reason to remove this behaviour:

In [15]: pd.to_timedelta(1, unit='W')
Out[15]: Timedelta('7 days 00:00:00')

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 a pull request may close this issue.

3 participants