title: DataFrame - Given a start date, end date , hours incurred daily, how do I go about calculating hours incurred for given month/year?
body: <p>i have a dataframe consisting of employee_id, start_date, end_date, hour_spent_per_day. basically for each record, it captures the hours spent per day for the employee and for the duration given bhy start_Date and end_Date.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">employee_id</th>
  <th style="text-align: center;">start_Date</th>
  <th style="text-align: right;">end_Date</th>
  <th style="text-align: left;">hours_spent_per_day</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">1234</td>
  <td style="text-align: center;">2019-01-15</td>
  <td style="text-align: right;">2019-01-15</td>
  <td style="text-align: left;">2</td>
  </tr>
  <tr>
  <td style="text-align: left;">1234</td>
  <td style="text-align: center;">2019-01-15</td>
  <td style="text-align: right;">2019-01-17</td>
  <td style="text-align: left;">3</td>
  </tr>
  <tr>
  <td style="text-align: left;">1236</td>
  <td style="text-align: center;">2019-01-29</td>
  <td style="text-align: right;">2019-02-28</td>
  <td style="text-align: left;">4</td>
  </tr>
  <tr>
  <td style="text-align: left;">1237</td>
  <td style="text-align: center;">2019-01-19</td>
  <td style="text-align: right;">2019-03-05</td>
  <td style="text-align: left;">2</td>
  </tr>
  <tr>
  <td style="text-align: left;">1237</td>
  <td style="text-align: center;">2019-12-01</td>
  <td style="text-align: right;">2020-01-10</td>
  <td style="text-align: left;">2</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>My objective is to have a summary of total hours spent per month per year.
  i.e.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">Year</th>
  <th style="text-align: center;">Month</th>
  <th style="text-align: left;">Hours Spent</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">2019</td>
  <td style="text-align: center;">January</td>
  <td style="text-align: left;">'hours spent for all the days in Jan-2019 for all employees</td>
  </tr>
  <tr>
  <td style="text-align: left;">2019</td>
  <td style="text-align: center;">February</td>
  <td style="text-align: left;">'hours spent for all the days in Feb-2019 for all employees</td>
  </tr>
  <tr>
  <td style="text-align: left;">2019</td>
  <td style="text-align: center;">March</td>
  <td style="text-align: left;">'hours spent for all the days in Mar-2019 for all employees</td>
  </tr>
  <tr>
  <td style="text-align: left;">2019</td>
  <td style="text-align: center;">December</td>
  <td style="text-align: left;">'hours spent for all the days in Dec-2019 for all employees</td>
  </tr>
  <tr>
  <td style="text-align: left;">2020</td>
  <td style="text-align: center;">January</td>
  <td style="text-align: left;">'hours spent for all the days in Jan-2020 for all employees</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Now the second table would be easy (just a matter of group by SQL) . However I am having problem with the first table , i.e. for each row, how do I determine the hours spent for each month (noting cross-month is possible). I guess I need to determine the exact month/year covered for each row and then multiply the hours spent for the month. i am stuck , seeking your kind assistance.</p>