dimanche 9 août 2020

Python : How to generate random dates with a 6 day frequency

Generate a df with columns name and date with 6 days frequency and count of 4 record for each name in list

start date : 01-07-2006

list :

list_names=['tom','mark']

expected output:


name    date
tom     01-07-2006
tom     07-07-2006     
tom     13-07-2006
tom     19-07-2006
mark    01-07-2006
mark    07-07-2006     
mark     13-07-2006
mark     19-07-2006

tried this :

from datetime import datetime

d1 = datetime.strptime('1/7/2006 1:30 PM', '%m/%d/%Y %I:%M %p')
d2 = datetime.strptime('1/8/2006 4:50 AM', '%m/%d/%Y %I:%M %p')

for i in range(4):
    print(random_date(d1, d2))



Aucun commentaire:

Enregistrer un commentaire