1

How could i replicate this line below as a forloop? This line worked:

data= data.resample('W').last()

data
date        result
2010-01-10  0.53
2010-01-17  0.55

To convert to a forloop, I tried this. This raises no error, but doesn't modify the data at all:

listxx = [(data, "data")]
for (x, y) in listxx:
    x = x.resample('W').last()
arv
  • 398
  • 1
  • 9
  • You can provide a sample of your data as shown here https://stackoverflow.com/q/20109391/6692898 – RichieV Jul 31 '20 at 13:01

1 Answers1

2
for i, (x, y) in enumerate(listxx):
    listxx[i] = x.resample('W').last()
RichieV
  • 5,103
  • 2
  • 11
  • 24
  • Would this work too for the second line: ```listxx[i] = x.set_index('date').dropna(how='all').resample('W').last()``` – arv Jul 31 '20 at 12:14
  • Anything you want to do to list[i] in terms of modifying it... just don't remove it. The loop is going through consecutive items and removing one item will cause unwanted results – RichieV Jul 31 '20 at 12:17