I have a list of dates with a format %y-%m-%d and a single value. I need to find all the dates that are more recent than value
dates = ['22-02-10','22-02-11','22-02-12','22-02-13','22-02-14','22-02-15']
value = '22-02-12'
the output should be false,false,false,true,true,true.
How can I perform this in a fast way without a for loop?
>Solution :
You can use numpy to let the underlying c implementation do the looping (which is way faster then pure python)
import numpy as np
dates = ['22-02-10','22-02-11','22-02-12','22-02-13','22-02-14','22-02-15']
value = '22-02-12'
dates = np.array(dates, dtype='datetime64')
value = np.array(value, dtype='datetime64')
print(dates > value)