问题陈述: 有2个数据帧A& B。
A:
Timestamp datetime64[ns, UTC]
CH_0 float64
CH_1 float64
CH_2 float64
B:
Video Start Time datetime64[ns, UTC]
Video End Time datetime64[ns, UTC]
Video Paused object
Pause Time (s) float64
Action object
我需要弄清楚在某个时间执行了什么动作 在Dataframe A中,其中的信息在B中可用 视频开始和结束时间的帮助。
已尝试解决方案
这是我目前正在尝试但无法修复的代码。
idx = pd.IntervalIndex(B['Video Start Time'],
B['Video End Time'],
closed='both',
dtype='interval[datetime64]')
event = B.loc[idx.get_indexer(A.Timestamp), 'Action']
A['event'] = event.values
错误 这是我遇到的错误。非常感谢任何建议。
TypeError: type <class 'numpy.datetime64'> with value 2017-10-31T03:38:18.006921000 is not an interval
示例数据集
A:
Timestamp CH_0 CH_1 CH_2
0 2017-10-31 03:38:18.214471+00:00 -323.590000 -59.662882 -1.197040
1 2017-10-31 03:38:18.215471+00:00 -323.552011 -43.198672 9.800288
2 2017-10-31 03:38:18.216471+00:00 -323.565635 -28.295482 19.331956
3 2017-10-31 03:38:18.217471+00:00 -323.567988 -12.937613 28.548840
4 2017-10-31 03:38:18.218471+00:00 -323.544373 3.961324 38.386562
5 2017-10-31 03:38:18.219471+00:00 -323.579086 18.777666 46.975722
6 2017-10-31 03:38:18.220471+00:00 -323.560907 28.281476 52.537818
7 2017-10-31 03:38:18.221471+00:00 -323.518415 31.308331 54.244971
8 2017-10-31 03:38:18.222471+00:00 -323.583354 27.252193 51.624331
9 2017-10-31 03:38:18.223471+00:00 -323.607014 15.752827 44.298533
B:
Video Start Time Video End Time
0 2017-10-31 03:38:18.006921+00:00 2017-10-31 03:41:48.394944+00:00
1 2017-10-31 03:41:48.394944+00:00 2017-10-31 03:43:35.261420+00:00
2 2017-10-31 03:43:35.261420+00:00 2017-10-31 03:45:35.498950+00:00
Video Paused Pause Time (s) Action
Y 41.247365 Relaxation
Y 13.392300 Play
N 0.000000 Work