How can I interpolate time series as follows?
>>> df=pd.DataFrame([1,2,np.nan,4],columns=['val'],index=pd.to_timedelta([1,2,3,4],unit='s'))
>>> df
val
00:00:01 1
00:00:02 2
00:00:03 NaN
00:00:04 4
The following interpolation does not work.
df.interpolate(method='time')
...
TypeError: Cannot cast array data from dtype('<m8[ns]') to dtype('float64') according to the rule 'safe'
Does anyone know why or some workarounds? Thanks for the help!
source
share