I need help on the below downsample time series problem and I’m not certain how to complete it. I have a given a try but no luck.
import pandas as pd
dataFrame = pd.read_csv(‘dow_jones_index.data’,parse_dates=[“date”], index_col=“date”)
dataFrame.head()
closeTS = dataFrame[(dataFrame.stock == ‘AA’)].close.str.replace(’$’,’ ').astype(float)
- downsample the data filtered in the above step day wise and perform interpolation to forward fill the first two ‘Nan’ values.
- return the first 10 samples of downsampled data to variable ‘downsample’
I tried the below
downsample1 = closeTS.resample(‘D’, fill_method=‘ffill’)
downsample = downsample1.interpolate(method=‘linear’,limit=None,limit_direction=‘forward’)
print(downsample.head(10))
but not working. Can someone help to downsample the below code.