title: Python: Ad column with average value for each row
body: <p>I have a dataframe which looks like this:</p>
  <pre><code>data1 = [['2020-10-01', '07-08', 3.0 ], ['2020-10-01', '08-09', 2.0], ['2020-10-01', '07-08', 3.0], ['2020-10-01', '07-08', 3.0],['2020-10-02', '07-08', 3.0 ], ['2020-10-02', '08-09', 3.0], ['2020-10-02', '07-08', 3.0], ['2020-10-02', '08-09', 3.0],  ['2020-10-03', '09-10', 9.0], ['2020-10-03', '09-10', 9.0]]
    
  df1 = pd.DataFrame(data1, columns = ['Date', 'TimeCategory', 'Value_TimeCategory_total'])
  </code></pre>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Date</th>
  <th>TimeCategory</th>
  <th>Value_TimeCategory_total</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>2020-10-01</td>
  <td>07-08</td>
  <td>3.0</td>
  </tr>
  <tr>
  <td>2020-10-01</td>
  <td>08-09</td>
  <td>2.0</td>
  </tr>
  <tr>
  <td>2020-10-01</td>
  <td>07-08</td>
  <td>3.0</td>
  </tr>
  <tr>
  <td>2020-10-01</td>
  <td>07-08</td>
  <td>3.0</td>
  </tr>
  <tr>
  <td>2020-10-02</td>
  <td>07-08</td>
  <td>3.0</td>
  </tr>
  <tr>
  <td>2020-10-02</td>
  <td>08-09</td>
  <td>3.0</td>
  </tr>
  <tr>
  <td>2020-10-02</td>
  <td>07-08</td>
  <td>3.0</td>
  </tr>
  <tr>
  <td>2020-10-02</td>
  <td>08-09</td>
  <td>3.0</td>
  </tr>
  <tr>
  <td>2020-10-03</td>
  <td>09-10</td>
  <td>9.0</td>
  </tr>
  <tr>
  <td>2020-10-03</td>
  <td>09-10</td>
  <td>9.0</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>The Dataframe contains the total values for each TimeCategory during one day.</p>
  <p>Now I would like to add a column to this dataframe which displays the average value for each TimeCategory during each day.</p>
  <p>If I have 3 rows for with date 2020-10-01 and with the TimeCategory 07-08 and the total value equals 3.0, I would like to have the average value equals 1.0.</p>
  <p>The result should look like this.</p>
  <pre><code>data2 = [['2020-10-01', '07-08', 3.0 , 1.0], ['2020-10-01', '08-09', 2.0, 2.0], ['2020-10-01', '07-08', 3.0, 1.0], ['2020-10-01', '07-08', 3.0, 1.0],['2020-10-02', '07-08', 3.0, 1.5 ], ['2020-10-02', '08-09', 3.0, 1.5], ['2020-10-02', '07-08', 3.0, 1.5], ['2020-10-02', '08-09', 3.0, 1.5], ['2020-10-03', '09-10', 9.0, 4.5], ['2020-10-03', '09-10', 9.0, 4.5]]
    
  df2 = pd.DataFrame(data2, columns = ['Date', 'TimeCategory', 'Value_TimeCategory_total' , 'Value_TimeCategory_Row_Average'])
    
  df2
  </code></pre>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Date</th>
  <th>TimeCategory</th>
  <th>Value_TimeCategory_total</th>
  <th>Value_TimeCategory_Row_Average</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>2020-10-01</td>
  <td>07-08</td>
  <td>3.0</td>
  <td>1.0</td>
  </tr>
  <tr>
  <td>2020-10-01</td>
  <td>08-09</td>
  <td>2.0</td>
  <td>2.0</td>
  </tr>
  <tr>
  <td>2020-10-01</td>
  <td>07-08</td>
  <td>3.0</td>
  <td>1.0</td>
  </tr>
  <tr>
  <td>2020-10-01</td>
  <td>07-08</td>
  <td>3.0</td>
  <td>1.0</td>
  </tr>
  <tr>
  <td>2020-10-02</td>
  <td>07-08</td>
  <td>3.0</td>
  <td>1.5</td>
  </tr>
  <tr>
  <td>2020-10-02</td>
  <td>08-09</td>
  <td>3.0</td>
  <td>1.5</td>
  </tr>
  <tr>
  <td>2020-10-02</td>
  <td>07-08</td>
  <td>3.0</td>
  <td>1.5</td>
  </tr>
  <tr>
  <td>2020-10-02</td>
  <td>08-09</td>
  <td>3.0</td>
  <td>1.5</td>
  </tr>
  <tr>
  <td>2020-10-03</td>
  <td>09-10</td>
  <td>9.0</td>
  <td>4.5</td>
  </tr>
  <tr>
  <td>2020-10-03</td>
  <td>09-10</td>
  <td>9.0</td>
  <td>4.5</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I do not want to use group by, because I need all rows (including duplicates) of my dataframe.</p>
  <p>Many thanks in advance for your help.</p>