title: Python Pandas - how to add columns of filtered sum and calculate percentage weight
body: <p>I would like to add two columns to a pandas df to show daily totals and weights. Existing df:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Date</th>
  <th>Name</th>
  <th>Value</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>2022-2-1</td>
  <td>Apple</td>
  <td>5</td>
  </tr>
  <tr>
  <td>2022-2-1</td>
  <td>Pear</td>
  <td>3</td>
  </tr>
  <tr>
  <td>2022-2-2</td>
  <td>Apple</td>
  <td>4</td>
  </tr>
  <tr>
  <td>2022-2-2</td>
  <td>Pear</td>
  <td>4</td>
  </tr>
  <tr>
  <td>2022-2-2</td>
  <td>Banana</td>
  <td>2</td>
  </tr>
  <tr>
  <td>2022-2-3</td>
  <td>Apple</td>
  <td>5</td>
  </tr>
  <tr>
  <td>2022-2-3</td>
  <td>Banana</td>
  <td>3</td>
  </tr>
  <tr>
  <td>2022-2-4</td>
  <td>Apple</td>
  <td>4</td>
  </tr>
  <tr>
  <td>2022-2-4</td>
  <td>Banana</td>
  <td>2</td>
  </tr>
  <tr>
  <td>2022-2-4</td>
  <td>Papaya</td>
  <td>9</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Desired output:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Date</th>
  <th>Name</th>
  <th style="text-align: right;">Value</th>
  <th style="text-align: right;">Daily Total</th>
  <th style="text-align: right;">Percentage Weight</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>2022-2-1</td>
  <td>Apple</td>
  <td style="text-align: right;">5</td>
  <td style="text-align: right;">8</td>
  <td style="text-align: right;">62.5%</td>
  </tr>
  <tr>
  <td>2022-2-1</td>
  <td>Pear</td>
  <td style="text-align: right;">3</td>
  <td style="text-align: right;">8</td>
  <td style="text-align: right;">37.5%</td>
  </tr>
  <tr>
  <td>2022-2-2</td>
  <td>Apple</td>
  <td style="text-align: right;">4</td>
  <td style="text-align: right;">10</td>
  <td style="text-align: right;">40%</td>
  </tr>
  <tr>
  <td>2022-2-2</td>
  <td>Pear</td>
  <td style="text-align: right;">4</td>
  <td style="text-align: right;">10</td>
  <td style="text-align: right;">40%</td>
  </tr>
  <tr>
  <td>2022-2-2</td>
  <td>Banana</td>
  <td style="text-align: right;">2</td>
  <td style="text-align: right;">10</td>
  <td style="text-align: right;">20%</td>
  </tr>
  <tr>
  <td>2022-2-3</td>
  <td>Apple</td>
  <td style="text-align: right;">5</td>
  <td style="text-align: right;">8</td>
  <td style="text-align: right;">62.5%</td>
  </tr>
  <tr>
  <td>2022-2-3</td>
  <td>Banana</td>
  <td style="text-align: right;">3</td>
  <td style="text-align: right;">8</td>
  <td style="text-align: right;">37.5%</td>
  </tr>
  <tr>
  <td>2022-2-4</td>
  <td>Apple</td>
  <td style="text-align: right;">4</td>
  <td style="text-align: right;">15</td>
  <td style="text-align: right;">26.7%</td>
  </tr>
  <tr>
  <td>2022-2-4</td>
  <td>Banana</td>
  <td style="text-align: right;">2</td>
  <td style="text-align: right;">15</td>
  <td style="text-align: right;">13.3%</td>
  </tr>
  <tr>
  <td>2022-2-4</td>
  <td>Papaya</td>
  <td style="text-align: right;">9</td>
  <td style="text-align: right;">15</td>
  <td style="text-align: right;">60%</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Appreciate any ideas/suggestions.</p>