I want to substract dates ignoring specific days (not only weekends but some other days, so Count number of days between dates, ignoring weekends doesn't work in that case).
Given a table referencing whether a day should count or not, how could I implement a substract function that ignore those days ?
data = {'Date':['2019-01-01', '2019-01-02', '2019-01-03', '2019-01-04'], 'key':[0, 0, 1, 0]}
df = pd.DataFrame(data)
If key == 1, then the day should not count (as a weekend day in the similar problem)
from datetime import datetime
date1 = datetime.strptime('2019-01-02 21:00:00', '%Y-%m-%d %H:%M:%S')
date2 = datetime.strptime('2019-01-04 17:00:00', '%Y-%m-%d %H:%M:%S')
date2-date1
Out[50]:
datetime.timedelta(days=1, seconds=72000)
Expected output : substract_function(date2,date1) should return 72000 seconds