This question already has an answer here:
I would like to create a list of n random datetime objects between a given start_date and end_date. Inspired by this similar thread, I created a function that accomplishes this in a following way:
def random_datetime_list_generator(start_date, end_date,n):
return ((start_date + timedelta(seconds=np.random.randint(0, (end_date - start_date).total_seconds()))) for i in xrange(n))
Does anybody have any better solution or can propose a more effective/faster/pythonic way of doing it?
Aucun commentaire:
Enregistrer un commentaire