I use Pandas and Numpy, and I'm trying to replace all the NaN values in a series like this:
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]
with the closest objcet (Numpy array in this case). Result:
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]
Does anyone know an effective method? Many thanks.