mars.dataframe.Series.dt.total_seconds#

Series.dt.total_seconds(*args, **kwargs)#

Return total duration of each element expressed in seconds.

This method is available directly on TimedeltaArray, TimedeltaIndex and on Series containing timedelta values under the .dt namespace.

Returns

seconds – When the calling object is a TimedeltaArray, the return type is ndarray. When the calling object is a TimedeltaIndex, the return type is a Float64Index. When the calling object is a Series, the return type is Series of type float64 whose index is the same as the original.

Return type

[ndarray, Float64Index, Series]

See also

datetime.timedelta.total_seconds

Standard library version of this method.

TimedeltaIndex.components

Return a DataFrame with components of each Timedelta.

Examples

Series

>>> import mars.tensor as mt
>>> import mars.dataframe as md
>>> s = md.Series(md.to_timedelta(mt.arange(5), unit='d'))
>>> s.execute()
0   0 days
1   1 days
2   2 days
3   3 days
4   4 days
dtype: timedelta64[ns]
>>> s.dt.total_seconds().execute()
0         0.0
1     86400.0
2    172800.0
3    259200.0
4    345600.0
dtype: float64

TimedeltaIndex

>>> idx = md.to_timedelta(mt.arange(5), unit='d')
>>> idx.execute()
TimedeltaIndex(['0 days', '1 days', '2 days', '3 days', '4 days'],
               dtype='timedelta64[ns]', freq=None)
>>> idx.total_seconds().execute()
Float64Index([0.0, 86400.0, 172800.0, 259200.00000000003, 345600.0],
             dtype='float64')