to_timedelta64

function of dascore.utils.time source

to_timedelta64(
    obj: float | numpy.ndarray | str | datetime.timedelta[float, ndarray, str, timedelta] ,
)

Convert an object to timedelta64.

This function accepts a wide range of inputs and returns something of the same shape, but converted to numpy’s timedelta64 representation.

Examples

# Convert a float to seconds
import dascore as dc
d_time_1 = dc.to_timedelta64(10.1232)
# also works on negative numbers
d_time_2 = dc.to_datetime64(-10.5)