lundi 8 juin 2020

Iterate over array with dateimes and select from a dataframe randomly another datetime [with constraints]

I have a list with biweekly datetimes and a dataframe with Weekly data (below is only part of the list and dataframe). In a loop I need to iterate over the Biweekly list such that:

-For every Biweekly datetime, randomly pick a Weekly date. However, that randomly picked Weekly date must be in the same month as the the Biweekly datetime or 1 month before or 1 month after.

Any suggestions how to do this in a nice and neat way?

Biweekly

Datetime            
2016-03-1 00:00     
2016-03-15 00:00   
2016-03-29 01:30    

Weekly

Datetime            Level1   Level2
2016-03-1 00:00     12       15
2016-03-8 00:00     11       17
2016-03-15 00:00    09       15
2016-03-29 00:00    12       15



Aucun commentaire:

Enregistrer un commentaire