import dascore as dc
# Convert a float to timedelta64 representing seconds.
= dc.to_timedelta64(10.1232)
td_1
# This also works on negative numbers.
= dc.to_datetime64(-10.5)
td_2
# Convert a string to timedelta64
= "1000000000 nanoseconds"
td_str = dc.to_timedelta64(td_str) td_3
to_timedelta64
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.
Parameters
Parameter | Description |
---|---|
obj |
An object to convert to timedelta64. Can be a float, str or arary of such. Floats are interpreted as seconds and strings must conform to the output style of timedeltas (e.g. str(time_delta)). |