pandas.Timedelta.view#

Timedelta.view(dtype)#

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:
dtypestr or dtype

The dtype to view the underlying data as.

See also

Timedelta.asm8

Return a numpy timedelta64 array scalar view.

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')
>>> td
Timedelta('3 days 00:00:00')
>>> td.view(int)
259200000000000