Skip to content

Commit fa8bcfd

Browse files
chalmerlowevictor
authored and
victor
committed
DOC: Improve the docstring of Timedelta.asm8 (pandas-dev#21821)
1 parent dc2ca92 commit fa8bcfd

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

pandas/_libs/tslibs/timedeltas.pyx

+31-1
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,37 @@ cdef class _Timedelta(timedelta):
834834

835835
@property
836836
def asm8(self):
837-
""" return a numpy timedelta64 array view of myself """
837+
"""
838+
Return a numpy timedelta64 array scalar view.
839+
840+
Provides access to the array scalar view (i.e. a combination of the
841+
value and the units) associated with the numpy.timedelta64().view(),
842+
including a 64-bit integer representation of the timedelta in
843+
nanoseconds (Python int compatible).
844+
845+
Returns
846+
-------
847+
numpy timedelta64 array scalar view
848+
Array scalar view of the timedelta in nanoseconds.
849+
850+
Examples
851+
--------
852+
>>> td = pd.Timedelta('1 days 2 min 3 us 42 ns')
853+
>>> td.asm8
854+
numpy.timedelta64(86520000003042,'ns')
855+
856+
>>> td = pd.Timedelta('2 min 3 s')
857+
>>> td.asm8
858+
numpy.timedelta64(123000000000,'ns')
859+
860+
>>> td = pd.Timedelta('3 ms 5 us')
861+
>>> td.asm8
862+
numpy.timedelta64(3005000,'ns')
863+
864+
>>> td = pd.Timedelta(42, unit='ns')
865+
>>> td.asm8
866+
numpy.timedelta64(42,'ns')
867+
"""
838868
return np.int64(self.value).view('m8[ns]')
839869

840870
@property

0 commit comments

Comments
 (0)