(dti: pd.DatetimeIndex)
return data
Convert datetime to epoch
Convert datetime to epoch
Convert datetime to epoch
def datetime_to_epoch(dti: pd.DatetimeIndex) -> np.ndarray:
    """Convert datetime to epoch"""
    data = dti.values.astype("M8[us]")
    mask = np.isnat(data)
    data = data.astype(float) / 1e6
    data[mask] = np.nan
    return data
def datetime_to_epoch ( dti : pd . DatetimeIndex ) -> np . ndarray : data = dti . values . astype ( "M8[us]" ) mask = np . isnat ( data ) data = data . astype ( float ) / 1e6 data [ mask ] = np . nan return data