pandas.arrays.TimedeltaArray

class pandas.arrays.TimedeltaArray(values, dtype=dtype('<m8[ns]'), freq=None, copy=False)[source]

Pandas ExtensionArray for timedelta data.

New in version 0.24.0.

Warning

TimedeltaArray is currently experimental, and its API may change without warning. In particular, TimedeltaArray.dtype is expected to change to be an instance of an ExtensionDtype subclass.

Parameters
valuesarray-like

The timedelta data.

dtypenumpy.dtype

Currently, only numpy.dtype("timedelta64[ns]") is accepted.

freqOffset, optional
copybool, default False

Whether to copy the underlying array of data.

Attributes

asi8

Integer representation of the values.

components

Return a dataframe of the components (days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) of the Timedeltas.

days

Number of days for each element.

dtype

The dtype for the TimedeltaArray.

freq

Return the frequency object if it is set, otherwise None.

freqstr

Return the frequency object as a string if its set, otherwise None

inferred_freq

Tryies to return a string representing a frequency guess, generated by infer_freq.

microseconds

Number of microseconds (>= 0 and less than 1 second) for each element.

nanoseconds

Number of nanoseconds (>= 0 and less than 1 microsecond) for each element.

nbytes

The number of bytes needed to store this object in memory.

resolution

Returns day, hour, minute, second, millisecond or microsecond

seconds

Number of seconds (>= 0 and less than 1 day) for each element.

shape

Return a tuple of the array dimensions.

size

The number of elements in this array.

Methods

argsort(self[, ascending, kind])

Return the indices that would sort this array.

astype(self, dtype[, copy])

Cast to a NumPy array with ‘dtype’.

ceil(self, freq[, ambiguous, nonexistent])

Perform ceil operation on the data to the specified freq.

copy(self[, deep])

Return a copy of the array.

dropna(self)

Return ExtensionArray without NA values

factorize(self, na_sentinel)

Encode the extension array as an enumerated type.

fillna(self[, value, method, limit])

Fill NA/NaN values using the specified method.

floor(self, freq[, ambiguous, nonexistent])

Perform floor operation on the data to the specified freq.

isna(self)

A 1-D array indicating if each value is missing.

max(self[, axis, skipna])

Return the maximum value of the Array or maximum along an axis.

min(self[, axis, skipna])

Return the minimum value of the Array or minimum along an axis.

repeat(self, repeats, \*args, \*\*kwargs)

Repeat elements of an array.

round(self, freq[, ambiguous, nonexistent])

Perform round operation on the data to the specified freq.

searchsorted(self, value[, side, sorter])

Find indices where elements should be inserted to maintain order.

shift(self, periods, fill_value)

Shift values by desired number.

take(self, indices[, allow_fill, fill_value])

Take elements from an array.

to_pytimedelta(self)

Return Timedelta Array/Index as object ndarray of datetime.timedelta objects.

total_seconds(self)

Return total duration of each element expressed in seconds.

unique(self)

Compute the ExtensionArray of unique values.

value_counts(self[, dropna])

Return a Series containing counts of unique values.

view(self[, dtype])

New view on this array with the same data.

map

Scroll To Top