0
I’m creating a data model for Machine Learning to get a transaction amount forecast per year/month/day/hour.
But I am needing to map the 5th and 10th working day of the month so that my algorithm predicts that are days of great movement and so the numbers are closer to real values.
I have already searched some libraries and found a name Workalendar, where I spend a date and what working day I need and it returns me the date, below follows an example of use.
from workalendar.america import Brazil
cal = Brazil()
print(cal.add_working_days(date(2019, 12, 1), 5))
...
2019-12-06
The problem is that I’m having trouble moving on to my variables 0 or 1 to validate that the working day is actually what I need. I tried to make a loop and scan the entire dataframe by passing the date and working day, however I could not find a way to inform that the returned value is valid or not. :(
Has anyone ever had this problem managed to solve this problem with some mathematical formula or something like that?
Note: I took a look at the library code to see if I could find something, but I didn’t quite understand how they calculate the working day n.
Just remembering that to count only working days you will have to consider the holidays, which can be national, state or municipal.
– anonimo
As for the holidays, I’m mapping them manually and merging to select whether a date is a business day or not. For example, if I could get the 5th working day but it was a state holiday the working day would be the next.
– ramonfsk
Put what you tried
– Tmilitino
I was making a "dumb" comparison, rsrs. I managed to solve my problem using the workalendar lib! ;)
– ramonfsk