From fdc0d393fa694b4fe4f1744b9f60afe100fee3bd Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Sun, 8 Jul 2018 11:34:28 -1000 Subject: [PATCH 1/2] DOC: Improve the docstring of Timedelta.asm8 --- pandas/_libs/tslibs/timedeltas.pyx | 32 +++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index a76ebc8000e54..e9d20ca69b566 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -829,7 +829,37 @@ cdef class _Timedelta(timedelta): @property def asm8(self): - """ return a numpy timedelta64 array view of myself """ + """ + Return a numpy timedelta64 array view. + + Provides access to the array view associated with the + numpy.timedelta64().view() including a 64-bit integer + representation of the timedelta in nanoseconds (Python int + compatible). + + Returns + ------- + numpy timedelta64 array view + Array view of the timedelta in nanoseconds. + + Examples + -------- + >>> td = pd.Timedelta('1 days 2 min 3 us 42 ns') + >>> td.asm8 + numpy.timedelta64(86520000003042,'ns') + + >>> td = pd.Timedelta('2 min 3 s') + >>> td.asm8 + numpy.timedelta64(123000000000,'ns') + + >>> td = pd.Timedelta('3 ms 5 us') + >>> td.asm8 + numpy.timedelta64(3005000,'ns') + + >>> td = pd.Timedelta(42, unit='ns') + >>> td.asm8 + numpy.timedelta64(42,'ns') + """ return np.int64(self.value).view('m8[ns]') @property From 06251ac8dfec283fa426a70db8eb5b6b0667ed71 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Mon, 9 Jul 2018 22:21:23 -1000 Subject: [PATCH 2/2] DOC: Improve the docstring of Timedelta.asm8 --- pandas/_libs/tslibs/timedeltas.pyx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index e9d20ca69b566..b9405b15a0980 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -830,17 +830,17 @@ cdef class _Timedelta(timedelta): @property def asm8(self): """ - Return a numpy timedelta64 array view. + Return a numpy timedelta64 array scalar view. - Provides access to the array view associated with the - numpy.timedelta64().view() including a 64-bit integer - representation of the timedelta in nanoseconds (Python int - compatible). + Provides access to the array scalar view (i.e. a combination of the + value and the units) associated with the numpy.timedelta64().view(), + including a 64-bit integer representation of the timedelta in + nanoseconds (Python int compatible). Returns ------- - numpy timedelta64 array view - Array view of the timedelta in nanoseconds. + numpy timedelta64 array scalar view + Array scalar view of the timedelta in nanoseconds. Examples --------