Skip to content

Commit b058e37

Browse files
ijmbarrWillAyd
authored andcommitted
DOC: Improved the docstring of pandas.Series.dt.components (pandas-dev#20177)
1 parent f90aa44 commit b058e37

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

pandas/core/indexes/accessors.py

+20-4
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,30 @@ def to_pytimedelta(self):
237237
@property
238238
def components(self):
239239
"""
240-
Return a dataframe of the components (days, hours, minutes,
241-
seconds, milliseconds, microseconds, nanoseconds) of the Timedeltas.
240+
Return a Dataframe of the components of the Timedeltas.
242241
243242
Returns
244243
-------
245-
a DataFrame
244+
DataFrame
246245
247-
"""
246+
Examples
247+
--------
248+
>>> s = pd.Series(pd.to_timedelta(np.arange(5), unit='s'))
249+
>>> s
250+
0 00:00:00
251+
1 00:00:01
252+
2 00:00:02
253+
3 00:00:03
254+
4 00:00:04
255+
dtype: timedelta64[ns]
256+
>>> s.dt.components
257+
days hours minutes seconds milliseconds microseconds nanoseconds
258+
0 0 0 0 0 0 0 0
259+
1 0 0 0 1 0 0 0
260+
2 0 0 0 2 0 0 0
261+
3 0 0 0 3 0 0 0
262+
4 0 0 0 4 0 0 0
263+
""" # noqa: E501
248264
return self._get_values().components.set_index(self.index)
249265

250266
@property

0 commit comments

Comments
 (0)