Skip to content

DEPR: depreecate uppercase units 'MIN', 'MS', 'US', 'NS' in Timedelta and 'to_timedelta' #57700

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

Conversation

natmokval
Copy link
Contributor

@natmokval natmokval commented Mar 1, 2024

Deprecated uppercase strings “MIN”, “MS”, “US”, “NS” denoting units from the class Timedelta and the method to_timedelta.

The reason: for period/offsets these strings are already deprecated. Instead of the uppercase strings we use lowercase: “min”, “ms”, “us”, “ns”.

FutureWarning,
stacklevel=find_stack_level(),
)
unit = unit.lower()
elif unit in c_DEPR_ABBREVS:
Copy link
Member

Choose a reason for hiding this comment

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

Instead of adding another branch is there any reason to not just add these to c_DEPR_ABBREVS?

Copy link
Contributor Author

@natmokval natmokval Mar 2, 2024

Choose a reason for hiding this comment

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

thank you, I agree, better to add these deprecated units to the dictionary. I made the changes.

Unfortunately, we can't add "MS" to c_DEPR_ABBREVS because we use that dictionary in the definition of to_offset, and in thus casee"MS" means "MonthBegin". For Timedelta, "ms" means milliseconds, so we want to deprecate "MS" for "Milli" to avoid confusion.

I wonder, can we get these changes into 2.2.x? The reason: we deprecated already uppercase strings “MIN”, “MS”, “US”, and “NS” denoting frequencies for Period and offsets in favor of lowercase strings.

Seems like CI failures aren't related to my changes.

Copy link
Member

Choose a reason for hiding this comment

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

we want to deprecate "MS" for "Milli" to avoid confusion.

sorry I might have missed something but where was this discussed? I don't remember it now. "month begin" isn't valid for timedelta, so I think there's no risk of confusion here?

I wonder, can we get these changes into 2.2.x?

there's already 2.2.0 and 2.2.1 out, I think it's too late now

Copy link
Member

Choose a reason for hiding this comment

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

As discussed: by

deprecate "MS" for "Milli"

you meant "deprecate "MS" for milliseconds", not

deprecate "MS" in favour of "Milli"

as I'd interpreted it

All good then 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, my wording wasn't clear enough. I meant: deprecate "MS" for milliseconds".

I updated Timedelta docstring, and added a note to v3.0.0, but I am unsure if we need the note, because using uppercase strings “MIN”, “MS”, “US”, “NS” for units are not documented.

Copy link
Member

Choose a reason for hiding this comment

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

same as in the other PR, shall we mark this as draft until we've enfored the existing deprecations, so that the codebase can get a little cleaner?

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, sounds reasonable, I marked this PR as draft.

@natmokval natmokval marked this pull request as ready for review March 2, 2024 22:04
@natmokval natmokval requested a review from MarcoGorelli as a code owner March 2, 2024 22:04
@natmokval natmokval added Deprecate Functionality to remove in pandas Timedelta Timedelta data type labels Mar 2, 2024
@natmokval natmokval requested a review from rhshadrach as a code owner March 7, 2024 14:08
@natmokval natmokval marked this pull request as draft March 13, 2024 12:17
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Apr 13, 2024
@natmokval
Copy link
Contributor Author

closed via #59051

@natmokval natmokval closed this Jun 27, 2024
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 Stale Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants