From 4dcb4b4d730dda1929f851dd16d54aee4c070ffc Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Tue, 15 May 2018 12:12:44 -0400 Subject: [PATCH 01/16] 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 02/16] 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 03/16] 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 04/16] 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 05/16] 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 06/16] 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 07/16] 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 08/16] 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 From 50357983a9e9debaba2dcb9bebcfe8de4590513f Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Wed, 16 May 2018 18:42:38 -0700 Subject: [PATCH 09/16] DOC: documentation guide update to resolution docstring --- pandas/_libs/tslibs/timedeltas.pyx | 43 +++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index f7bb6c1dbb304..89f97a77026f9 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -770,7 +770,48 @@ cdef class _Timedelta(timedelta): @property def resolution(self): - """ return a string representing the lowest resolution that we have """ + """ + Return a string representing the lowest (i.e. smallest) time resolution. + + Each timedelta has a defined resolution that represents the lowest OR + most granular level of precision. Each level of resolution is + represented by a short string as defined below: + + - Days: 'D' + - Hours: 'H' + - Minutes: 'T' + - Seconds: 'S' + - Milliseconds: 'L' + - Microseconds: 'U' + - Nanoseconds: 'N' + + Returns + ------- + str + Time resolution. + + Examples + -------- + **Using string input** + + >>> td = pd.Timedelta('1 days 2 min 3 us 42 ns') + >>> td.resolution + 'N' + + >>> td = pd.Timedelta('1 days 2 min 3 us') + >>> td.resolution + 'U' + + >>> td = pd.Timedelta('2 min 3 s') + >>> td.resolution + 'S' + + **Using integer input** + + >>> td = pd.Timedelta(36, unit='us') + >>> td.resolution + 'U' + """ self._ensure_components() if self._ns: From 23a8aae9ede4b234c221e7e123abf191d1f539c3 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Fri, 18 May 2018 06:12:28 -1000 Subject: [PATCH 10/16] DOC: Improve docstring of Timedelta.resolution --- pandas/_libs/tslibs/timedeltas.pyx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 89f97a77026f9..270d1e20ba0e4 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -777,6 +777,18 @@ cdef class _Timedelta(timedelta): most granular level of precision. Each level of resolution is represented by a short string as defined below: + ============ ============ + Resolution Return value + ============ ============ + Days 'D' + Hours 'H' + Minutes 'T' + Seconds 'S' + Milliseconds 'L' + Microseconds 'U' + Nanoseconds 'N' + ============ ============ + - Days: 'D' - Hours: 'H' - Minutes: 'T' From 2c91847d9de14615dc4458589a24137218e65065 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Fri, 18 May 2018 07:17:12 -1000 Subject: [PATCH 11/16] DOC: Improve docstring of Timedelta.resolution --- pandas/_libs/tslibs/timedeltas.pyx | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 270d1e20ba0e4..00cd46d2277b4 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -780,23 +780,15 @@ cdef class _Timedelta(timedelta): ============ ============ Resolution Return value ============ ============ - Days 'D' - Hours 'H' - Minutes 'T' - Seconds 'S' - Milliseconds 'L' - Microseconds 'U' - Nanoseconds 'N' + Days ``'D'`` + Hours ``'H'`` + Minutes ``'T'`` + Seconds ``'S'`` + Milliseconds ``'L'`` + Microseconds ``'U'`` + Nanoseconds ``'N'`` ============ ============ - - Days: 'D' - - Hours: 'H' - - Minutes: 'T' - - Seconds: 'S' - - Milliseconds: 'L' - - Microseconds: 'U' - - Nanoseconds: 'N' - Returns ------- str From 83da2fed8810bd6edd6015d30c0dcd12f5cb52ee Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Fri, 18 May 2018 07:31:43 -1000 Subject: [PATCH 12/16] DOC: Improve the docstring of Timedelta.resolution --- pandas/_libs/tslibs/timedeltas.pyx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 00cd46d2277b4..cfbab9984922a 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -771,20 +771,21 @@ cdef class _Timedelta(timedelta): @property def resolution(self): """ - Return a string representing the lowest (i.e. smallest) time resolution. + Return a string representing the lowest (i.e. smallest) time + resolution. - Each timedelta has a defined resolution that represents the lowest OR - most granular level of precision. Each level of resolution is + Each timedelta has a defined resolution that represents the lowest OR + most granular level of precision. Each level of resolution is represented by a short string as defined below: ============ ============ Resolution Return value - ============ ============ + ============ ============ Days ``'D'`` Hours ``'H'`` Minutes ``'T'`` Seconds ``'S'`` - Milliseconds ``'L'`` + Milliseconds ``'L'`` Microseconds ``'U'`` Nanoseconds ``'N'`` ============ ============ @@ -815,7 +816,7 @@ cdef class _Timedelta(timedelta): >>> td = pd.Timedelta(36, unit='us') >>> td.resolution 'U' - """ + """ self._ensure_components() if self._ns: From 764f91a5ba5fd5b9f7891d81381af7a0669a0c6c Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Fri, 18 May 2018 17:28:49 -1000 Subject: [PATCH 13/16] DOC: Improve the docstring of Timedelta.resolution --- 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 cfbab9984922a..c409c7bbedd67 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -781,13 +781,13 @@ cdef class _Timedelta(timedelta): ============ ============ Resolution Return value ============ ============ - Days ``'D'`` - Hours ``'H'`` - Minutes ``'T'`` - Seconds ``'S'`` - Milliseconds ``'L'`` - Microseconds ``'U'`` - Nanoseconds ``'N'`` + Days 'D' + Hours 'H' + Minutes 'T' + Seconds 'S' + Milliseconds 'L' + Microseconds 'U' + Nanoseconds 'N' ============ ============ Returns From 886f21ac4000f14adc39005266ecffe65229fe19 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Sat, 19 May 2018 09:20:40 -1000 Subject: [PATCH 14/16] Minor edits as suggested --- pandas/_libs/tslibs/timedeltas.pyx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index c409c7bbedd67..ddcfec5706e07 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -771,8 +771,7 @@ cdef class _Timedelta(timedelta): @property def resolution(self): """ - Return a string representing the lowest (i.e. smallest) time - resolution. + Return a string representing the lowest timedelta resolution. Each timedelta has a defined resolution that represents the lowest OR most granular level of precision. Each level of resolution is @@ -793,12 +792,10 @@ cdef class _Timedelta(timedelta): Returns ------- str - Time resolution. + Timedelta resolution. Examples -------- - **Using string input** - >>> td = pd.Timedelta('1 days 2 min 3 us 42 ns') >>> td.resolution 'N' @@ -811,8 +808,6 @@ cdef class _Timedelta(timedelta): >>> td.resolution 'S' - **Using integer input** - >>> td = pd.Timedelta(36, unit='us') >>> td.resolution 'U' From 5737c673665225c21e04084f216505a789b43766 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Fri, 6 Jul 2018 19:46:06 -1000 Subject: [PATCH 15/16] DOC: Improve the docstring of Timedelta.resolution --- pandas/_libs/tslibs/timedeltas.pyx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index ddcfec5706e07..5e5deeb6013ac 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -770,24 +770,22 @@ cdef class _Timedelta(timedelta): @property def resolution(self): - """ + """ Return a string representing the lowest timedelta resolution. Each timedelta has a defined resolution that represents the lowest OR most granular level of precision. Each level of resolution is represented by a short string as defined below: - ============ ============ - Resolution Return value - ============ ============ - Days 'D' - Hours 'H' - Minutes 'T' - Seconds 'S' - Milliseconds 'L' - Microseconds 'U' - Nanoseconds 'N' - ============ ============ + Resolution: Return value + + * Days: 'D' + * Hours: 'H' + * Minutes: 'T' + * Seconds: 'S' + * Milliseconds: 'L' + * Microseconds: 'U' + * Nanoseconds: 'N' Returns ------- From ce7c795fd9f58866f0450c40cf395d038a0db351 Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Sat, 7 Jul 2018 23:50:38 -0500 Subject: [PATCH 16/16] remove whitespace --- 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 4525956d009d9..a76ebc8000e54 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -834,7 +834,7 @@ cdef class _Timedelta(timedelta): @property def resolution(self): - """ + """ Return a string representing the lowest timedelta resolution. Each timedelta has a defined resolution that represents the lowest OR