title: How to get sum and average of values from a pandas dataframe using values in multiple lists?
body: <p>I've the following dataframe -</p>
  <pre><code>df1
  </code></pre>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Location</th>
  <th>Office</th>
  <th>ROP</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Barcelona</td>
  <td>Head Office</td>
  <td>4.3%</td>
  </tr>
  <tr>
  <td>Bengaluru</td>
  <td>Corporate Office</td>
  <td>9.6%</td>
  </tr>
  <tr>
  <td>Chicago</td>
  <td>Head Office</td>
  <td>12.5%</td>
  </tr>
  <tr>
  <td>Luxembourg</td>
  <td>Corporate Office</td>
  <td>14.1%</td>
  </tr>
  <tr>
  <td>Paris</td>
  <td>Head Office</td>
  <td>12.7%</td>
  </tr>
  <tr>
  <td>Toronto</td>
  <td>Head Office</td>
  <td>11.5%</td>
  </tr>
  <tr>
  <td>Berlin</td>
  <td>Corporate Office</td>
  <td>14.3%</td>
  </tr>
  <tr>
  <td>Bengaluru</td>
  <td>Head Office</td>
  <td>4.6%</td>
  </tr>
  <tr>
  <td>Luxembourg</td>
  <td>Head Office</td>
  <td>7.1%</td>
  </tr>
  <tr>
  <td>Berlin</td>
  <td>Head Office</td>
  <td>5.3%</td>
  </tr>
  <tr>
  <td>Luxembourg</td>
  <td>Virtual Center</td>
  <td>10.1%</td>
  </tr>
  <tr>
  <td>Berlin</td>
  <td>Virtual Center</td>
  <td>12.3%</td>
  </tr>
  <tr>
  <td>Paris</td>
  <td>Virtual Center</td>
  <td>9.7%</td>
  </tr>
  <tr>
  <td>:</td>
  <td>:</td>
  <td>:</td>
  </tr>
  <tr>
  <td>:</td>
  <td>:</td>
  <td>:</td>
  </tr>
  <tr>
  <td>:</td>
  <td>:</td>
  <td>:</td>
  </tr>
  </tbody>
  </table>
  </div>
  <pre><code>a = ['Berlin','Paris','Luxembourg',...]
  b = ['Head Office','Corporate Office',..]
  </code></pre>
  <p>Say there are multiple values in lists a and b, how do I find the sum and average of ROP based on the values in the lists and the given dataframe?</p>
  <p><strong>Example:</strong></p>
  <p>Say we have data from above mentioned dataframe in 'df2'.</p>
  <p>df2 has just the visible 13 rows from dataframe 'df1'.</p>
  <p>a = ['Berlin','Paris','Luxembourg']</p>
  <p>b = ['Head Office','Corporate Office']</p>
  <p><strong>Expected output:</strong></p>
  <p>Sum: 14.3%+5.3%+12.7%+7.1%+14.1% = 53.5%</p>
  <p>Average: (14.3%+5.3%+12.7%+7.1%+14.1%)/5 = 10.7%</p>