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: deprecate unit parameters ’T’, 't', 'L', and 'l' #53557

Merged

Conversation

natmokval
Copy link
Contributor

@natmokval natmokval commented Jun 7, 2023

Added upper case ’T’ for minutes in UnitChoices list. Now mypy doesn’t raise an error.

Update:
Deprecated unit parameters ’T’, 't', 'L', 'l', and fixed test.

@natmokval natmokval marked this pull request as ready for review June 8, 2023 20:58
@natmokval
Copy link
Contributor Author

@jbrockmendel, could you please take a look at this pr?

@natmokval natmokval changed the title BUG: add ’T’ to UnitChoices to fix incorrect unit validation in to_timedelta() DEPR: deprecate unit parameters ’T’, 't', 'L', and 'l' Jun 8, 2023
@@ -181,6 +181,9 @@ def to_timedelta(
"represent unambiguous timedelta values durations."
)

if unit in {"t", "T", "l", "L"}:
raise ValueError("Units 't', 'T', 'l' and 'L' are no longer supported.")
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for working on this - there should probably be a FutureWarning first, and then in version 3.0 these units can raise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comment. I’ll replace raising ValueError with FutureWarning.

@mroeschke mroeschke added the Deprecate Functionality to remove in pandas label Jun 9, 2023
@jbrockmendel
Copy link
Member

along with these i think we need to track down other places where we use/allow these codes. _attrname_to_abbrevs/_abbrev_to_attrnames and Tick._prefix come to mind. Doesn't need to be this PR, but hopefully a follow-on

@natmokval natmokval force-pushed the BUG-incorrect-unit-validation-for-T branch from b089fa0 to d2a673f Compare June 19, 2023 08:42
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Nice one!

Test failures are probably unrelated, if we fetch/merge upstream/main after they're fixed then hopefully it'll all be good

@MarcoGorelli MarcoGorelli added this to the 2.1 milestone Jun 19, 2023
@natmokval
Copy link
Contributor Author

Thank you @MarcoGorelli for reviewing this pr.

@MarcoGorelli
Copy link
Member

merging then, thanks!

@MarcoGorelli MarcoGorelli merged commit cbfe215 into pandas-dev:main Jun 20, 2023
31 of 34 checks passed
canthonyscott pushed a commit to canthonyscott/pandas-anthony that referenced this pull request Jun 23, 2023
)

* BUG: add ’T’ to UnitChoices to fix incorrect unit validation in to_timedelta()

* deprecate units T, t, L, l and fix tests

* raise FutureWarning instead of ValueError

* correct the to_timedelta definition and add a test for the warning

---------

Co-authored-by: Marco Edward Gorelli <marcogorelli@protonmail.com>
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
)

* BUG: add ’T’ to UnitChoices to fix incorrect unit validation in to_timedelta()

* deprecate units T, t, L, l and fix tests

* raise FutureWarning instead of ValueError

* correct the to_timedelta definition and add a test for the warning

---------

Co-authored-by: Marco Edward Gorelli <marcogorelli@protonmail.com>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Either incorrect unit validation for 'T' in to_timedelta() or incorrect documentation
4 participants