I have a pandas dataframe df, which has GDP values alsong with yyyy-mm TimePeriod index.
import numpy as np
import pandas as pd
import pandas_datareader.data as web
gdp = web.DataReader("GDP", "fred", start, end).resample('M').mean().interpolate(method='linear').round().to_period('M')
Date GDP
2015-07 16528.0
2015-08 16534.0
2015-09 16541.0
2015-10 16548.0
2015-11 16556.0
2015-12 16564.0
2016-01 16572.0
2016-02 16602.0
2016-03 16633.0
2016-04 16664.0
2016-05 16702.0
2016-06 16740.0
2016-07 16778.0
2016-08 16803.0
2016-09 16827.0
2016-10 16851.0
2016-11 16869.0
2016-12 16886.0
2017-01 16903.0
2017-02 16946.0
2017-03 16988.0
2017-04 17031.0
2017-05 17075.0
2017-06 17120.0
2017-07 17164.0
2017-08 NaN
2017-09 NaN
2017-10 NaN
2017-11 NaN
2017-12 NaN
GDP is published quarterly. The latest data point is 2017 Q3. So I resampled to have monthly values and interpolated when the values were missing. How do I extrapolate to fill up the remaining of the NaN for the rest of the year by using spline or 3 month moving average etc? I have seen some examples using polynomial, but that look like overdoing stuff (pandas extrapolation of polynomial). I was wondering if there is a simpler approach. Thank you!