From 3202b20791a082b4c7bc0d35b80966cef0014dcf Mon Sep 17 00:00:00 2001 From: ijmbarr Date: Sat, 10 Mar 2018 16:16:08 +0100 Subject: [PATCH 1/3] DOC: Improved the docstring of pandas.Series.dt.components --- pandas/core/indexes/accessors.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/pandas/core/indexes/accessors.py b/pandas/core/indexes/accessors.py index c5b300848876e..3ce43753d730e 100644 --- a/pandas/core/indexes/accessors.py +++ b/pandas/core/indexes/accessors.py @@ -162,13 +162,34 @@ def to_pytimedelta(self): @property def components(self): """ - Return a dataframe of the components (days, hours, minutes, - seconds, milliseconds, microseconds, nanoseconds) of the Timedeltas. + Return a Dataframe of the components of the Timedeltas. + + Provides a dataframe with the components of each of the timedeltas with + the same length and index as the original Series, and columns: + + (days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) Returns ------- - a DataFrame - + a : pandas.DataFrame + + Examples + -------- + >>> s = pd.Series(pd.to_timedelta(np.arange(5), unit='s')) + >>> s + 0 00:00:00 + 1 00:00:01 + 2 00:00:02 + 3 00:00:03 + 4 00:00:04 + dtype: timedelta64[ns] + >>> s.dt.components + days hours minutes seconds milliseconds microseconds nanoseconds + 0 0 0 0 0 0 0 0 + 1 0 0 0 1 0 0 0 + 2 0 0 0 2 0 0 0 + 3 0 0 0 3 0 0 0 + 4 0 0 0 4 0 0 0 """ return self._get_values().components.set_index(self.index) From ec3860f35c8491ac89183e40ac3627ba463883e7 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Sun, 8 Jul 2018 10:19:41 -0500 Subject: [PATCH 2/3] Simplified docstring --- pandas/core/indexes/accessors.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pandas/core/indexes/accessors.py b/pandas/core/indexes/accessors.py index 947639db8b8f4..28677c52ef7bb 100644 --- a/pandas/core/indexes/accessors.py +++ b/pandas/core/indexes/accessors.py @@ -239,14 +239,9 @@ def components(self): """ Return a Dataframe of the components of the Timedeltas. - Provides a dataframe with the components of each of the timedeltas with - the same length and index as the original Series, and columns: - - (days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) - Returns ------- - a : pandas.DataFrame + DataFrame Examples -------- From d1ddfb2e2ef2ee6eac026c59fccb208b9c2845d0 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Sun, 8 Jul 2018 10:24:46 -0500 Subject: [PATCH 3/3] LINT exception --- pandas/core/indexes/accessors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexes/accessors.py b/pandas/core/indexes/accessors.py index 28677c52ef7bb..d7b4ea63cd48c 100644 --- a/pandas/core/indexes/accessors.py +++ b/pandas/core/indexes/accessors.py @@ -260,7 +260,7 @@ def components(self): 2 0 0 0 2 0 0 0 3 0 0 0 3 0 0 0 4 0 0 0 4 0 0 0 - """ + """ # noqa: E501 return self._get_values().components.set_index(self.index) @property