# Question on Downsample

**URL:** <https://discuss.python.org/t/question-on-downsample/5923>\
**Category:** Python Help\
**Created:** [November 27, 2020, 3:53pm UTC](https://discuss.python.org/t/question-on-downsample/5923 "2020-11-27T15:53:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gan123sub](https://avatars.discourse-cdn.com/v4/letter/g/3ec8ea/32.png) [@gan123sub](https://discuss.python.org/u/gan123sub)\
**Post date:** [November 27, 2020, 3:53pm UTC](https://discuss.python.org/t/question-on-downsample/5923/1 "2020-11-27T15:53:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![HardeepSiinghh](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/hardeepsiinghh/32/3203_2.png) [@HardeepSiinghh](https://discuss.python.org/u/HardeepSiinghh)\
**Post date:** [December 29, 2020, 9:49am UTC](https://discuss.python.org/t/question-on-downsample/5923/2 "2020-12-29T09:49:58Z")

</div>

downsample = closeTS.resample(‘D’, fill\_method=‘ffill’, limit=2).head(10)

---

<div class="post-metadata">

**Author:** ![steven.daprano](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/steven.daprano/32/1083_2.png) [@steven.daprano](https://discuss.python.org/u/steven.daprano)\
**Post date:** [December 29, 2020, 11:56am UTC](https://discuss.python.org/t/question-on-downsample/5923/3 "2020-12-29T11:56:36Z")

</div>

What’s your question?

---

<div class="post-metadata">

**Author:** ![HardeepSiinghh](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/hardeepsiinghh/32/3203_2.png) [@HardeepSiinghh](https://discuss.python.org/u/HardeepSiinghh)\
**Post date:** [December 30, 2020, 9:55am UTC](https://discuss.python.org/t/question-on-downsample/5923/4 "2020-12-30T09:55:00Z")

</div>

- 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’

These two are the questions.

---

<div class="post-metadata">

**Author:** ![gan123sub](https://avatars.discourse-cdn.com/v4/letter/g/3ec8ea/32.png) [@gan123sub](https://discuss.python.org/u/gan123sub)\
**Post date:** [December 30, 2020, 11:38am UTC](https://discuss.python.org/t/question-on-downsample/5923/5 "2020-12-30T11:38:52Z")

</div>

Thank you, the solution by Hardeep worked. Thanks a lot.
