我有多个从CSV文件导入的timeseries数据。 这些数据都有时间戳,但时间戳并不总是匹配的:
时间序列1:
UUT Data
DateTime
2017-11-21 18:54:31 uut1 1
2017-11-22 02:26:48 uut1 2
2017-11-22 10:19:44 uut1 3
2017-11-22 15:11:28 uut1 6
2017-11-22 23:21:58 uut1 7
时间序列2:
^{pr2}$我可以使用concat函数将它们连接在一起并按“UUT”分组,但是,如何用前面的值填充空的时隙,使最终表看起来类似于:
DateTime UUT Data
11/21/17 18:47:29 uut1 1
11/21/17 18:54:31 1
11/22/17 2:26:48 2
11/22/17 2:26:49 2
11/22/17 10:19:44 3
11/22/17 15:11:28 6
11/22/17 15:17:47 6
11/22/17 23:21:58 7
11/23/17 7:10:56 8
11/23/17 15:15:48 8
11/23/17 15:22:16 9
11/24/17 12:16:58 11
11/21/17 18:47:29 uut2 1
11/21/17 18:54:31 1
11/22/17 2:26:48 1
11/22/17 2:26:49 2
11/22/17 10:19:44 3
11/22/17 15:11:28 3
11/22/17 15:17:47 4
11/22/17 23:21:58 5
11/23/17 7:10:56 6
11/23/17 15:15:48 7
11/23/17 15:22:16 7
11/24/17 12:16:58 9
或者说:
DateTime uut1 uut2
11/21/17 18:47:29 1 1
11/21/17 18:54:31 1 1
11/22/17 2:26:48 2 1
11/22/17 2:26:49 2 2
11/22/17 10:19:44 3 3
11/22/17 15:11:28 6 3
11/22/17 15:17:47 6 4
11/22/17 23:21:58 7 5
11/23/17 7:10:56 8 6
11/23/17 15:15:48 8 7
11/23/17 15:22:16 9 7
11/24/17 12:16:58 11 9
我的最终目标是能够在一个timeseries图上同时绘制uut1和uut2数据。在
找到索引与
index.union
,reindex
数据帧,concat
,然后pivot
的并集,以获得所需的输出。在最后,使用
^{pr2}$df.plot
-相关问题 更多 >
编程相关推荐