@@ -500,7 +500,57 @@ def f(x):
500500
501501 def total_seconds (self ):
502502 """
503- Total duration of each element expressed in seconds.
503+ Return total duration of each element expressed in seconds.
504+
505+ This method is available directly on TimedeltaIndex and on Series
506+ containing timedelta values under the ``.dt`` namespace.
507+
508+ Returns
509+ -------
510+ seconds : Float64Index or Series
511+ When the calling object is a TimedeltaIndex, the return type is a
512+ Float64Index. When the calling object is a Series, the return type
513+ is Series of type `float64` whose index is the same as the
514+ original.
515+
516+ See Also
517+ --------
518+ datetime.timedelta.total_seconds : Standard library version
519+ of this method.
520+ TimedeltaIndex.components : Return a DataFrame with components of
521+ each Timedelta.
522+
523+ Examples
524+ --------
525+ **Series**
526+
527+ >>> s = pd.Series(pd.to_timedelta(np.arange(5), unit='d'))
528+ >>> s
529+ 0 0 days
530+ 1 1 days
531+ 2 2 days
532+ 3 3 days
533+ 4 4 days
534+ dtype: timedelta64[ns]
535+
536+ >>> s.dt.total_seconds()
537+ 0 0.0
538+ 1 86400.0
539+ 2 172800.0
540+ 3 259200.0
541+ 4 345600.0
542+ dtype: float64
543+
544+ **TimedeltaIndex**
545+
546+ >>> idx = pd.to_timedelta(np.arange(5), unit='d')
547+ >>> idx
548+ TimedeltaIndex(['0 days', '1 days', '2 days', '3 days', '4 days'],
549+ dtype='timedelta64[ns]', freq=None)
550+
551+ >>> idx.total_seconds()
552+ Float64Index([0.0, 86400.0, 172800.0, 259200.00000000003, 345600.0],
553+ dtype='float64')
504554 """
505555 return Index (self ._maybe_mask_results (1e-9 * self .asi8 ),
506556 name = self .name )
0 commit comments