title: Apply the average to a timedelta column for two group conditions
body: <p>I have the following dataframe in Python:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ID</th>
  <th>country_ID</th>
  <th>visit_time</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>0</td>
  <td>ESP</td>
  <td>10 days 12:03:00</td>
  </tr>
  <tr>
  <td>0</td>
  <td>ENG</td>
  <td>5 days 10:02:00</td>
  </tr>
  <tr>
  <td>1</td>
  <td>ENG</td>
  <td>3 days  08:05:03</td>
  </tr>
  <tr>
  <td>1</td>
  <td>ESP</td>
  <td>1 days    03:02:00</td>
  </tr>
  <tr>
  <td>1</td>
  <td>ENG</td>
  <td>2 days   07:01:03</td>
  </tr>
  <tr>
  <td>1</td>
  <td>ENG</td>
  <td>3 days  01:00:52</td>
  </tr>
  <tr>
  <td>2</td>
  <td>ENG</td>
  <td>0 days 12:01:02</td>
  </tr>
  <tr>
  <td>2</td>
  <td>ENG</td>
  <td>1 days 22:10:03</td>
  </tr>
  <tr>
  <td>2</td>
  <td>ENG</td>
  <td>0 days 20:00:50</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>For each ID, I want to get:</p>
  <p><strong>avg_visit_ESP and avg_visit_ENG columns.</strong></p>
  <ul>
  <li>Average time visit with country_ID = ESP for each ID.</li>
  <li>Average time visit with country_ID = ENG for each ID.</li>
  </ul>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ID</th>
  <th>avg_visit_ESP</th>
  <th>avg_visit_ENG</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>0</td>
  <td>10 days 12:03:00</td>
  <td>5 days 10:02:00</td>
  </tr>
  <tr>
  <td>1</td>
  <td>1 days 03:02:00</td>
  <td>(8 days 16:06:58) / 3</td>
  </tr>
  <tr>
  <td>2</td>
  <td>NaT</td>
  <td>(3 days 06:11:55) / 3</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I don't know how to specify in groupby a double grouping, first by ID and then by country_ID. If you can help me I would appreciate it.</p>
  <p>P.S.: The date format of visit_time (timedelta), can perform addition and division without any apparent problem.</p>
  <pre><code>from datetime import datetime, timedelta
      date1 = pd.to_datetime('2022-02-04 10:10:21', format='%Y-%m-%d %H:%M:%S')
      date2 = pd.to_datetime('2022-02-05 20:15:41', format='%Y-%m-%d %H:%M:%S')
      date3 = pd.to_datetime('2022-02-07 20:15:41', format='%Y-%m-%d %H:%M:%S')
      sum1date = date2-date1
      sum2date = date3-date2
      sum3date = date3-date1
      print((sum1date+sum2date+sum3date)/3)
  </code></pre>