lundi 1 juin 2020

Python - Generate random dates to create Gantt sequenced tasks

The idea is to generate random but sequenced dates based on workload estimation in python.

The goal is to have an output like this:

Task, Start_date, End_date
task1, 01/06/2020, 05/06/2020
task2, 08/06/2020, 11/06/2020
task3, 12/06/2020, 24/06/2020
...

So I started to work on this code but unable to find a way to randomize it.

#startdate
start_date = datetime.date(2020, 1, 1)
#enddate
end_date = datetime.date(2020, 2, 1)
time_between_dates = end_date - start_date
days_between_dates = time_between_dates.days
#workload in days
random_number_of_days = random.randrange(days_between_dates)
random_date = start_date + datetime.timedelta(days=random_number_of_days)

Any idea on how to randomize?




Aucun commentaire:

Enregistrer un commentaire