How do you attach the last calibration to a sensor reading?
merge_asof joins sorted tables by key proximity. A backward join finds the latest right-hand key at or before each left-hand key.
merge_asof in practice
A reading at 10:02 uses the 10:00 calibration even if another arrives at 10:05. Group by device and set a tolerance to reject overly old calibrations.
中文
如何把传感器读数关联到最近一次校准?
merge_asof 可以按时间邻近关系连接已排序的表。backward 方向为左表记录寻找不晚于它的最近键。
merge_asof 应用实例
传感器在 10:02 取样,校准发生于 10:00 和 10:05,应取 10:00。用 by 区分设备,并用 tolerance 限制可接受的校准间隔。