填写缺失的pandas数据帧(时间序列)数据与上次有效

时间:2015-06-25 23:49:09

标签: pandas

让我保存我有两个时间序列数据的DataFrame。

如何用最后一个有效值填写NaN?

所以,

2014-01-23 07:00:00.698708  428.75      NaN
2014-01-23 07:00:19.783769  428.75      NaN
2014-01-23 07:00:22.089900  429.00      NaN
2014-01-23 07:00:22.089900  429.00      NaN
2014-01-23 07:00:22.096339  429.00      NaN
2014-01-23 07:00:15.991013     NaN  1283.75
2014-01-23 07:00:25.280246     NaN  1284.00
2014-01-23 07:00:31.746926     NaN  1284.00
2014-01-23 07:00:31.747813     NaN  1284.00
2014-01-23 07:00:50.055061     NaN  1284.00
2014-01-23 07:00:56.467059     NaN  1284.25

应该是:

2014-01-23 07:00:00.698708  428.75      NaN
2014-01-23 07:00:19.783769  428.75      NaN
2014-01-23 07:00:22.089900  429.00      NaN
2014-01-23 07:00:22.089900  429.00      NaN
2014-01-23 07:00:22.096339  429.00      NaN
2014-01-23 07:00:15.991013     429.00  1283.75
2014-01-23 07:00:25.280246     429.00  1284.00
2014-01-23 07:00:31.746926     429.00  1284.00
2014-01-23 07:00:31.747813     429.00  1284.00
2014-01-23 07:00:50.055061     429.00  1284.00
2014-01-23 07:00:56.467059     429.00  1284.25

谢谢!

0 个答案:

没有答案