diff --git a/pandas/core/indexes/accessors.py b/pandas/core/indexes/accessors.py index 08d4de972bc06..d7b4ea63cd48c 100644 --- a/pandas/core/indexes/accessors.py +++ b/pandas/core/indexes/accessors.py @@ -237,14 +237,30 @@ 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. Returns ------- - a DataFrame + 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 + """ # noqa: E501 return self._get_values().components.set_index(self.index) @property