In detail, ex: I have a list weekday:
list_week_day = [0,2,4,5,6]
if today.weekday() = 3 , then order list_week_day = [4,5,6,0,2]
So, how to do that ???
In detail, ex: I have a list weekday:
list_week_day = [0,2,4,5,6]
if today.weekday() = 3 , then order list_week_day = [4,5,6,0,2]
So, how to do that ???
new = old[n:] + old[:n]
You append the front part of the list to the back part. Can you finish after that hint? n is your weekday.
Did you try the following? I suspect it is not the most efficient way to get what you desire, but it certainly is a way to get it.
list_week_day[today.weekday() : ] + list_week_day[ : today.weekday()]
Could also try:
wday = 3
[(x + wday) % 7 for x in list_week_day]
# [3, 4, 5, 6, 0, 1, 2]
As suggested here, you can use numpy's roll command, choosing a suitable value to roll by:
>>> import numpy
>>> a=numpy.arange(1,10) #Generate some data
>>> numpy.roll(a,1)
array([9, 1, 2, 3, 4, 5, 6, 7, 8])
>>> numpy.roll(a,-1)
array([2, 3, 4, 5, 6, 7, 8, 9, 1])
>>> numpy.roll(a,5)
array([5, 6, 7, 8, 9, 1, 2, 3, 4])
>>> numpy.roll(a,9)
array([1, 2, 3, 4, 5, 6, 7, 8, 9])