我正在使用Pandas和Numpy而我正试图替换系列中的所有NaN值,如下所示:
date a
2017-04-24 01:00:00 [1,0,0]
2017-04-24 01:20:00 [1,0,0]
2017-04-24 01:40:00 NaN
2017-04-24 02:00:00 NaN
2017-04-24 02:20:00 [0,1,0]
2017-04-24 02:40:00 [1,0,0]
2017-04-24 03:00:00 NaN
2017-04-24 03:20:00 [0,0,1]
2017-04-24 03:40:00 NaN
2017-04-24 04:00:00 [1,0,0]
与最近的objcet(在这种情况下为Numpy数组)。结果是:
date a
2017-04-24 01:00:00 [1,0,0]
2017-04-24 01:20:00 [1,0,0]
2017-04-24 01:40:00 [1,0,0]
2017-04-24 02:00:00 [0,1,0]
2017-04-24 02:20:00 [0,1,0]
2017-04-24 02:40:00 [1,0,0]
2017-04-24 03:00:00 [1,0,0]
2017-04-24 03:20:00 [0,0,1]
2017-04-24 03:40:00 [0,0,1]
2017-04-24 04:00:00 [1,0,0]
有人知道这样做的有效方法吗?非常感谢。