5

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!

Community
  • 1
  • 1
Ramprasath
  • 119
  • 9
  • 1
    Can you add some sample with desired output? 3,4 rows. – jezrael Jan 09 '17 at 08:29
  • Thank you. But I think it is unclear what means `business days` and `weekdays` - it means all days? So need differenceonly in hours `8:00-18:00` in all days? – jezrael Jan 09 '17 at 08:47
  • Yes.The difference must not take Saturday and Sunday into account and hours outside 8:00 to 18:00 should not be included. Say, my response time is 17:00 today and resolve time is 9:00 tomorrow. Answer should be 2 hrs. – Ramprasath Jan 09 '17 at 08:57
  • Ok, Time is with seconds or only minutes with hours? – jezrael Jan 09 '17 at 09:00
  • 1
    This may help .. https://pypi.python.org/pypi/BusinessHours/ – ashishsingal Jan 09 '17 at 14:45

1 Answers1

1

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

Ramprasath
  • 119
  • 9