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 with passed unit M, Y #16344

Closed
jorisvandenbossche opened this issue May 12, 2017 · 1 comment

Comments

@jorisvandenbossche
Copy link
Member

commented May 12, 2017

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 this to the Next Major Release milestone May 12, 2017

@jorisvandenbossche

This comment has been minimized.

Copy link
Member Author

commented May 12, 2017

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
Projects
None yet
3 participants
You can’t perform that action at this time.