Represents a duration, the difference between two dates or times.
Timedelta is the pandas equivalent of pythonâs datetime.timedelta
and is interchangeable with it in most cases.
Input value.
If input is an integer, denote the unit of the input. If input is a float, denote the unit of the integer parts. The decimal parts with resolution lower than 1 nanosecond are ignored.
Possible values:
âWâ, or âDâ
âdaysâ, or âdayâ
âhoursâ, âhourâ, âhrâ, or âhâ
âminutesâ, âminuteâ, âminâ, or âmâ
âsecondsâ, âsecondâ, âsecâ, or âsâ
âmillisecondsâ, âmillisecondâ, âmillisâ, âmilliâ, or âmsâ
âmicrosecondsâ, âmicrosecondâ, âmicrosâ, âmicroâ, or âusâ
ânanosecondsâ, ânanosecondâ, ânanosâ, ânanoâ, or ânsâ.
Deprecated since version 3.0.0: Allowing the values w, d, MIN, MS, US and NS to denote units are deprecated in favour of the values W, D, min, ms, us and ns.
Available kwargs: {days, seconds, microseconds, milliseconds, minutes, hours, weeks}. Values for construction in compat with datetime.timedelta. Numpy ints and floats will be coerced to python ints and floats.
Notes
The constructor may take in either both values of value and unit or kwargs as above. Either one of them must be used during initialization
The .value
attribute is always in ns.
If the precision is higher than nanoseconds, the precision of the duration is truncated to nanoseconds.
Examples
Here we initialize Timedelta object with both value and unit
>>> td = pd.Timedelta(1, "D") >>> td Timedelta('1 days 00:00:00')
Here we initialize the Timedelta object with kwargs
>>> td2 = pd.Timedelta(days=1) >>> td2 Timedelta('1 days 00:00:00')
We see that either way we get the same result
Attributes
Methods
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4