更新时间:2023-02-26 15:50:04
isin 将是实现此目的的好方法.但是,最简单的方法是将传感器时间数据展平为单个DatetimeIndex
,因此您可以将其与参考DatetimeIndex
进行比较.
isin would be good way of doing this. However, the easiest way of doing this would be to flatten your sensor time data into a single DatetimeIndex
so you can compare it with a reference DatetimeIndex
.
# creating reference DatetimeIndex idx_ref with a minute frequency
end=datetime.now().replace(second=0, microsecond=0)
dt = end - timedelta(days=1)
idx_ref = pd.DatetimeIndex(start=dt, end=end,freq='min')
# idx_dat represents your DatetimeIndex from the sensor
gaps = idx_ref[~idx_ref.isin(idx_dat)]
假设您只对时间间隔感兴趣.
Assuming you are only interested in the time gaps of course.