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

Add unit property and as_unit method to Timestamp, Timedelta and NaTType #864

Merged

Conversation

skatsuta
Copy link
Contributor

@skatsuta skatsuta commented Feb 12, 2024

Add unit property and as_unit method to Timestamp, Timedelta and NaTType.

Adding them to DatetimeIndex, TimedeltaIndex and Series.dt will be done in #865.

@skatsuta skatsuta marked this pull request as ready for review February 12, 2024 05:18
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

Suggest using TimeUnit that is now in pandas.

pandas-stubs/_libs/tslibs/nattype.pyi Outdated Show resolved Hide resolved
tests/test_scalars.py Outdated Show resolved Hide resolved
@skatsuta skatsuta force-pushed the add-as-unit-to-timestamp-and-timedelta branch from 3517aa2 to 9fca549 Compare February 13, 2024 13:16
Copy link
Contributor Author

@skatsuta skatsuta left a comment

Choose a reason for hiding this comment

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

@Dr-Irv Thanks for your suggestion.

Defined the TimeUnit type alias and used it throughout the stubs.

Also rebased to resolve conflicts with the main branch, so apologize if additional changes are not clear.

Will update #865 to use TimeUnit as well once this PR gets merged.

@skatsuta skatsuta requested a review from Dr-Irv February 13, 2024 13:41
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

thanks @skatsuta

@Dr-Irv Dr-Irv merged commit fdbe1df into pandas-dev:main Feb 13, 2024
13 checks passed
@skatsuta skatsuta deleted the add-as-unit-to-timestamp-and-timedelta branch February 13, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timestamp.as_unit "Timestamp" has no attribute "as_unit" [attr-defined]
2 participants