to_float

function of dascore.utils.time source

to_float(
    obj ,
)-> ‘pd.Series | np.ndarray | float’

Convert various datetime/timedelta things to a float.

Time offsets represent seconds, and datetimes are seconds from 1970. A pint quantity of time is converted to seconds as well; any other quantity raises UnitError, since a length or a data size has no float representation here.

A Series stays a Series and any other sequence becomes an array; every other input, null included, comes back as a scalar. A quantity follows its own magnitude, so an array-valued one yields an array.