Question is
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))
however above code does not seem to work
Try this:
downsample = closeTS.resample('D', fill_method='ffill', limit=2).head(10)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.