From 4dcb4b4d730dda1929f851dd16d54aee4c070ffc Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Tue, 15 May 2018 12:12:44 -0400 Subject: [PATCH 1/8] updated docstring for nanoseconds function --- pandas/_libs/tslibs/timedeltas.pyx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 7aeff9bec75b5..c3bfecbd8e312 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -789,9 +789,17 @@ cdef class _Timedelta(timedelta): @property def nanoseconds(self): """ - Number of nanoseconds (>= 0 and less than 1 microsecond). + Return the number of nanoseconds (n), where 0 <= n < 1 microsecond. + + Returns + ------- + int + Number of nanoseconds - .components will return the shown components + See Also + -------- + Timedelta.components : Return all attributes with assigned values (i.e. + days, seconds, microseconds, nanoseconds) """ self._ensure_components() return self._ns From 11a926695c83fc571977751acd48b139ac577334 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Tue, 15 May 2018 13:08:29 -0400 Subject: [PATCH 2/8] DOC: updated docstring for nanoseconds function per doc guidelines --- pandas/_libs/tslibs/timedeltas.pyx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 195a340eddb1d..d3802708a06f7 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -795,8 +795,7 @@ cdef class _Timedelta(timedelta): Returns ------- - int - Number of nanoseconds + int : Number of nanoseconds See Also -------- From 04e204b890a3b3a9ae2b940df9c494a89536a336 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Tue, 15 May 2018 15:46:17 -0400 Subject: [PATCH 3/8] DOC: added examples to nanoseconds function and minor formatting edits --- pandas/_libs/tslibs/timedeltas.pyx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index d3802708a06f7..9f33cf848af56 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -795,12 +795,27 @@ cdef class _Timedelta(timedelta): Returns ------- - int : Number of nanoseconds + int + Number of nanoseconds. See Also -------- Timedelta.components : Return all attributes with assigned values (i.e. - days, seconds, microseconds, nanoseconds) + days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds). + + + Examples + -------- + >>> td = pd.Timedelta('1 days 2 min 3 us 42 ns') + >>> td.nanoseconds + 42 + + **Using integer inputs** + + >>> td = pd.Timedelta(42, unit='ns') + >>> td.nanoseconds + 42 + """ self._ensure_components() return self._ns From 5ac6ef1e8996b943f03809cc1909ed03ff351bbb Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Tue, 15 May 2018 15:50:10 -0400 Subject: [PATCH 4/8] DOC: added example header --- pandas/_libs/tslibs/timedeltas.pyx | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 9f33cf848af56..463a33e3d4354 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -806,6 +806,7 @@ cdef class _Timedelta(timedelta): Examples -------- + **Using string input** >>> td = pd.Timedelta('1 days 2 min 3 us 42 ns') >>> td.nanoseconds 42 From fb457597996b340a5e545afedb7454fe2bbbb3df Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Tue, 15 May 2018 15:51:27 -0400 Subject: [PATCH 5/8] DOC: added example header and space --- pandas/_libs/tslibs/timedeltas.pyx | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 463a33e3d4354..98fae717664b6 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -807,6 +807,7 @@ cdef class _Timedelta(timedelta): Examples -------- **Using string input** + >>> td = pd.Timedelta('1 days 2 min 3 us 42 ns') >>> td.nanoseconds 42 From b0977f4042bf704191a863a370b63304260cc200 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Tue, 15 May 2018 15:55:14 -0400 Subject: [PATCH 6/8] DOC: fixed minor spelling error --- pandas/_libs/tslibs/timedeltas.pyx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 98fae717664b6..b2ad7113a2efe 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -803,7 +803,6 @@ cdef class _Timedelta(timedelta): Timedelta.components : Return all attributes with assigned values (i.e. days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds). - Examples -------- **Using string input** @@ -812,12 +811,11 @@ cdef class _Timedelta(timedelta): >>> td.nanoseconds 42 - **Using integer inputs** + **Using integer input** >>> td = pd.Timedelta(42, unit='ns') >>> td.nanoseconds 42 - """ self._ensure_components() return self._ns From 85bcb525c7f0a9c87e77be3c96583d917cc298a6 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Wed, 16 May 2018 13:00:32 -0400 Subject: [PATCH 7/8] removed trailing whitespace, long lines --- pandas/_libs/tslibs/timedeltas.pyx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index b2ad7113a2efe..cdf95ffe50a2d 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -800,8 +800,9 @@ cdef class _Timedelta(timedelta): See Also -------- - Timedelta.components : Return all attributes with assigned values (i.e. - days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds). + Timedelta.components : Return all attributes with assigned values + (i.e. days, hours, minutes, seconds, milliseconds, microseconds, + nanoseconds). Examples -------- @@ -815,7 +816,7 @@ cdef class _Timedelta(timedelta): >>> td = pd.Timedelta(42, unit='ns') >>> td.nanoseconds - 42 + 42 """ self._ensure_components() return self._ns From 42373917fe49a8cb42381197d3089305521b1669 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Wed, 16 May 2018 14:35:47 -0700 Subject: [PATCH 8/8] DOC: updates to docstring for nanoseconds function per doc guidelines --- pandas/_libs/tslibs/timedeltas.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 7f0431d0e48bf..f7bb6c1dbb304 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -792,7 +792,7 @@ cdef class _Timedelta(timedelta): def nanoseconds(self): """ Return the number of nanoseconds (n), where 0 <= n < 1 microsecond. - + Returns ------- int