Skip to content

DOC: fix SA01,ES01 for pandas.Timedelta.view #59733

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

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Timedelta.resolution PR02" \
-i "pandas.Timedelta.to_timedelta64 SA01" \
-i "pandas.Timedelta.total_seconds SA01" \
-i "pandas.Timedelta.view SA01" \
-i "pandas.TimedeltaIndex.nanoseconds SA01" \
-i "pandas.TimedeltaIndex.seconds SA01" \
-i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \
Expand Down
15 changes: 15 additions & 0 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1458,11 +1458,26 @@ cdef class _Timedelta(timedelta):
"""
Array view compatibility.

This method allows you to reinterpret the underlying data of a Timedelta
object as a different dtype. The `view` method provides a way to reinterpret
the internal representation of the `Timedelta` object without modifying its
data. This is particularly useful when you need to work with the underlying
data directly, such as for performance optimizations or interfacing with
low-level APIs. The returned value is typically the number of nanoseconds
since the epoch, represented as an integer or another specified dtype.

Parameters
----------
dtype : str or dtype
The dtype to view the underlying data as.

See Also
--------
numpy.ndarray.view : Returns a view of an array with the same data.
Timedelta.to_numpy : Converts the Timedelta to a NumPy timedelta64.
Timedelta.total_seconds : Returns the total duration of the Timedelta
object in seconds.

Examples
--------
>>> td = pd.Timedelta('3D')
Expand Down
Loading