pandas.Timedelta
-
class pandas.Timedelta -
Represents a duration, the difference between two dates or times.
Timedelta is the pandas equivalent of python’s
datetime.timedeltaand is interchangeable with it in most cases.Parameters: -
value : Timedelta, timedelta, np.timedelta64, string, or integer -
unit : str, optional -
Denote the unit of the input, if input is an integer. Default ‘ns’. Possible values: {‘Y’, ‘M’, ‘W’, ‘D’, ‘days’, ‘day’, ‘hours’, hour’, ‘hr’, ‘h’, ‘m’, ‘minute’, ‘min’, ‘minutes’, ‘T’, ‘S’, ‘seconds’, ‘sec’, ‘second’, ‘ms’, ‘milliseconds’, ‘millisecond’, ‘milli’, ‘millis’, ‘L’, ‘us’, ‘microseconds’, ‘microsecond’, ‘micro’, ‘micros’, ‘U’, ‘ns’, ‘nanoseconds’, ‘nano’, ‘nanos’, ‘nanosecond’, ‘N’}
- days, seconds, microseconds,
-
milliseconds, minutes, hours, weeks : numeric, optional -
Values for construction in compat with datetime.timedelta. np ints and floats will be coerced to python ints and floats.
Notes
The
.valueattribute is always in ns.Attributes
asm8Return a numpy timedelta64 array scalar view. componentsReturn a Components NamedTuple-like daysNumber of days. deltaReturn the timedelta in nanoseconds (ns), for internal compatibility. microsecondsNumber of microseconds (>= 0 and less than 1 second). nanosecondsReturn the number of nanoseconds (n), where 0 <= n < 1 microsecond. resolutionReturn a string representing the lowest timedelta resolution. secondsNumber of seconds (>= 0 and less than 1 day). freq is_populated value Methods
ceilreturn a new Timedelta ceiled to this resolution floorreturn a new Timedelta floored to this resolution isoformatFormat Timedelta as ISO 8601 Duration like P[n]Y[n]M[n]DT[n]H[n]M[n]S, where the[n]s are replaced by the values.roundRound the Timedelta to the specified resolution to_pytimedeltareturn an actual datetime.timedelta object note: we lose nanosecond resolution if any to_timedelta64Returns a numpy.timedelta64 object with ‘ns’ precision total_secondsTotal duration of timedelta in seconds (to ns precision) viewarray view compat -
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.24.2/reference/api/pandas.Timedelta.html