Python Forum

Full Version: looping for time while skipping a day
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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
Thanks for your suggestion, works well