pandas.TimedeltaIndex — pandas 3.0.0.dev0+2103.g41968a550a documentation (original) (raw)

class pandas.TimedeltaIndex(data=None, freq=<no_default>, dtype=None, copy=False, name=None)[source]#

Immutable Index of timedelta64 data.

Represented internally as int64, and scalars returned Timedelta objects.

Parameters:

dataarray-like (1-dimensional), optional

Optional timedelta-like data to construct index with.

freqstr or pandas offset object, optional

One of pandas date offset strings or corresponding objects. The string'infer' can be passed in order to set the frequency of the index as the inferred frequency upon creation.

dtypenumpy.dtype or str, default None

Valid numpy dtypes are timedelta64[ns], timedelta64[us],timedelta64[ms], and timedelta64[s].

copybool

Make a copy of input array.

nameobject

Name to be stored in the index.

Attributes

Methods

Notes

To learn more about the frequency strings, please seethis link.

Examples

pd.TimedeltaIndex(["0 days", "1 days", "2 days", "3 days", "4 days"]) TimedeltaIndex(['0 days', '1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', freq=None)

We can also let pandas infer the frequency when possible.

pd.TimedeltaIndex(np.arange(5) * 24 * 3600 * 1e9, freq="infer") TimedeltaIndex(['0 days', '1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', freq='D')