Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding time difference including business days and business hours in Pandas

Tags:

python

pandas

I have a dataframe with two datetime columns: ResponseTime and ResolveTime. My requirement is to get the difference between two datetimes in hours. The answer must include only business hours (8:00-18:00) and weekdays. I tried the following questions: Extract Business Days in Time Series using Python/Pandas and Mask timeseries outside business hours. I am new to Time series and I am not sure as to how I should use indexer_between_time. Desired output will be a dataframe like this:

Response Time,Resolve Time,Solving Time
'2013-01-01 04:00:00', '2013-01-01 05:00:00',1
'2013-01-01 04:00:00', '2013-01-01 05:30:00',1.5

Thanks!

like image 286
Ramprasath Avatar asked Nov 09 '22 03:11

Ramprasath


1 Answers

Of course, Business Hours package solves the need.Here is the code I found in github and it works perfect. It is also easy to tweak the code to our need. https://github.com/dnel/BusinessHours

like image 146
Ramprasath Avatar answered Nov 14 '22 23:11

Ramprasath