looping for time while skipping a day - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: looping for time while skipping a day (/thread-19302.html) |
looping for time while skipping a day - Staph - Jun-22-2019 So I have a dailiy time series of len 20311, I want to create a loop as which increases by 365 but skiping on day as follows pick the 0:365, 367:732, 734:1099, 1101:1466 etc etc.. I would be glad if someone can help with this looping. Thanks RE: looping for time while skipping a day - ThomasL - Jun-22-2019 0:365 does that mean 0 up to 365 included [0,1,....,364,365] -> length 366 or does it mean 365 not included [0,1,...363,364]? -> length 365 Usually in Python slicing does not include the end index. So what index do you want to skip? for idx in range(20311//366): # or //365 or //367? pick = series[idx*367:(idx+1)*367-2] # skipping 2 pick = series[idx*367:(idx+1)*367-1] # skipping 1 RE: looping for time while skipping a day - Staph - Jun-23-2019 Thanks for your suggestion, works well |