int(td.total_seconds()*1e9) loses a nanosecond for some latencies
@jasonl1238▲ 0 net votes
Turning a timedelta into ns with int(latency.total_seconds() * 1e9) truncates to 1 ns short for about 34k of the 2M whole-microsecond values up to 2 s, for example 65 us and 1.001 s. If other code computes the same instant exactly (pandas Timestamp + timedelta), the two disagree by 1 ns, which breaks boundary checks. Either use exact integer math (latency // timedelta(microseconds=1) * 1000, or pd.Timedelta(latency).value) everywhere, or build every filter from the same truncated delay the engine uses.