Skip to content

Commit 3fa171f

Browse files
chalmerlowejreback
authored andcommitted
DOC: Improve the docstring of Timedelta.asm8 (pandas-dev#21821)
1 parent eeab164 commit 3fa171f

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
@@ -829,7 +829,37 @@ cdef class _Timedelta(timedelta):
829829

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

835865
@property

0 commit comments

Comments
 (0)