pandas 1.4.2

NotesParametersBackRef

Timedelta is the pandas equivalent of python's datetime.timedelta and is interchangeable with it in most cases.

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.

Parameters

value : Timedelta, timedelta, np.timedelta64, str, or int
unit : str, default 'ns'

Denote the unit of the input, if input is an integer.

Possible values:

  • 'W', 'D', 'T', 'S', 'L', 'U', or 'N'

  • 'days' or 'day'

  • 'hours', 'hour', 'hr', or 'h'

  • 'minutes', 'minute', 'min', or 'm'

  • 'seconds', 'second', or 'sec'

  • 'milliseconds', 'millisecond', 'millis', or 'milli'

  • 'microseconds', 'microsecond', 'micros', or 'micro'

  • 'nanoseconds', 'nanosecond', 'nanos', 'nano', or 'ns'.

**kwargs :

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.

Represents a duration, the difference between two dates or times.

Examples

Here we initialize Timedelta object with both value and unit

This example is valid syntax, but we were not able to check execution
>>> td = pd.Timedelta(1, "d")
... td Timedelta('1 days 00:00:00')

Here we initialize the Timedelta object with kwargs

This example is valid syntax, but we were not able to check execution
>>> td2 = pd.Timedelta(days=1)
... td2 Timedelta('1 days 00:00:00')

We see that either way we get the same result

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

pandas.core.indexes.timedeltas.TimedeltaIndex

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/_libs/tslibs/timedeltas.cpython-39-darwin.so#None
type: <class 'type'>
Commit: