title: How can I calculate custom made business hours between two date columns for an entire dataframe? (output as a new column so I can chart it)
body: <p>Consider:</p>
  <pre><code>from business_duration import businessDuration
  
  import holidays as pyholidays
  
  start_date = df['assigned_at']
  
  end_date = df['completion_date']
  
  biz_open_time=time(9,0,0)
  
  biz_close_time=time(16,0,0)
  
  US_holiday_list = pyholidays.US(state='CA')
  
  unit_hour='hour'
  </code></pre>
  <p>When I try applying this code to my data frame, I get this error:</p>
  <p><code>df['business_sla'] = businessDuration(startdate=start_date, enddate=end_date, starttime=biz_open_time, endtime=biz_close_time, holidaylist=US_holiday_list, unit=unit_hour)</code></p>
  <pre><code>ValueError                                Traceback (most recent
  call last)
  &lt;ipython-input-22-4c73e233f159&gt; in &lt;module&gt;
  ----&gt; 1 df['business_sla'] =
  businessDuration(startdate=start_date, enddate=end_date,
  starttime=biz_open_time, endtime=biz_close_time,
  holidaylist=US_holiday_list, unit=unit_hour)
  
  
  ValueError: The truth value of a Series is ambiguous. Use
  a.empty, a.bool(), a.item(), a.any() or a.all().
  </code></pre>
  <p>Is it not possible to iterate over my entire data frame?</p>
  <p>I am trying to count the business hours for tasks to see how long it takes a user to complete it. I only want to count business hours, and some analysts work Saturdays as their business day, and some alternate Sundays (e.g., Tuesday through Saturday).</p>
  <p><strong>If Jason, in this example, works Saturdays, all cases on Saturday need to be counted 9-5 pm for him. <em>Also</em> if John and James alternate Sundays, then all cases assigned to them on their Sundays need to be counted only 9-5 for tasks placed in their name</strong></p>
  <p>Essentially, every day of the week needs to count 9-5 pm for the business hours tracking, just looking to exclude Saturdays for some, and exclude Sundays for others while counting all other days.</p>
  <p>My data frame looks like this now:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>product type</th>
  <th>analyst_name</th>
  <th>assigned_at</th>
  <th>completed_at</th>
  <th>duration</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>product A</td>
  <td>john</td>
  <td>2021-09-13</td>
  <td>2021-09-13</td>
  <td>0 Days 00:38:00</td>
  </tr>
  <tr>
  <td>product B</td>
  <td>james</td>
  <td>2021-09-13</td>
  <td>2021-09-13</td>
  <td>0 Days 00:59:00</td>
  </tr>
  <tr>
  <td>product A</td>
  <td>jason</td>
  <td>2021-09-13</td>
  <td>2021-09-13</td>
  <td>0 Days 01:01:00</td>
  </tr>
  <tr>
  <td>product A</td>
  <td>john</td>
  <td>2021-09-10</td>
  <td>2021-09-13</td>
  <td>3 Days 00:45:00</td>
  </tr>
  <tr>
  <td>product B</td>
  <td>james</td>
  <td>2021-09-10</td>
  <td>2021-09-13</td>
  <td>3 Days 01:16:00</td>
  </tr>
  <tr>
  <td>product A</td>
  <td>jason</td>
  <td>2021-09-10</td>
  <td>2021-09-13</td>
  <td>3 Days 01:30:0</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Cases assigned on Friday are counting the entire time the task was live until Monday it was finished.</p>
  <p>Example:</p>
  <p>If they were assigned at 4 pm on Friday, I want to count only one hour Friday, and then the time Monday morning at 9 am until completion.</p>
  <p>The new data frame would look more like this (assuming that all analysts didn't do their deals assigned on Friday at 4 pm. I'm adding one hour to their SLA + their time to work them on Monday morning):</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>product type</th>
  <th>analyst_name</th>
  <th>assigned_at</th>
  <th>completed_at</th>
  <th>duration</th>
  <th>business_hours_sla</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>product A</td>
  <td>john</td>
  <td>2021-09-13</td>
  <td>2021-09-13</td>
  <td>0 Days 00:38:00</td>
  <td>0 Days 00:38:00</td>
  </tr>
  <tr>
  <td>product B</td>
  <td>james</td>
  <td>2021-09-13</td>
  <td>2021-09-13</td>
  <td>0 Days 00:59:00</td>
  <td>0 Days 00:59:00</td>
  </tr>
  <tr>
  <td>product A</td>
  <td>jason</td>
  <td>2021-09-13</td>
  <td>2021-09-13</td>
  <td>0 Days 01:01:00</td>
  <td>0 Days 01:01:00</td>
  </tr>
  <tr>
  <td>product A</td>
  <td>john</td>
  <td>2021-09-10</td>
  <td>2021-09-13</td>
  <td>3 Days 00:45:00</td>
  <td>0 Days 01:45:00</td>
  </tr>
  <tr>
  <td>product B</td>
  <td>james</td>
  <td>2021-09-10</td>
  <td>2021-09-13</td>
  <td>3 Days 01:16:00</td>
  <td>0 Days 02:16:00</td>
  </tr>
  <tr>
  <td>product A</td>
  <td>jason</td>
  <td>2021-09-10</td>
  <td>2021-09-13</td>
  <td>3 Days 01:30:0</td>
  <td>0 Days 02:30:0</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>The third-party package: <em><a href="https://pypi.org/project/business-duration/" rel="nofollow noreferrer">Business_Duration</a></em></p>