Skip to content Skip to sidebar Skip to footer

Linearly Interpolating Pandas Time Series

I am pulling data on exchange rates using Pandas. The data does not have values for every single day. I'd like to fill in the missing time series using Pandas interoplate function

Solution 1:

You need to resample first:

df.resample('D').interpolate(method='linear')
Out: 
             DEXCAUS
DATE                
2010-01-04  1.037700
2010-01-05  1.037100
2010-01-06  1.033300
2010-01-07  1.035100
2010-01-08  1.034500
2010-01-09  1.033567
2010-01-10  1.032633
2010-01-11  1.031700
2010-01-12  1.037400
2010-01-13  1.031900
2010-01-14  1.026000
2010-01-15  1.028700

Post a Comment for "Linearly Interpolating Pandas Time Series"