title: pandas - extract values greater than a threshold from a column
body: <p>I have a DataFrame - a snapshot of which looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/4YCgd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4YCgd.png" alt="enter image description here"></a></p>
  
  <p>I am trying to grab all the <code>math_score</code> and <code>reading_score</code> values greater than 70 grouped by <code>school_name</code>. </p>
  
  <p>So my end result should look something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Z1pMZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z1pMZ.png" alt="enter image description here"></a></p>
  
  <p>I am trying to calculate the % of students with a passing <code>math_score</code> and <code>reading_score</code> which is % of scores > 70.</p>
  
  <p>Any help on how I can go about this? </p>
  
  <p>This is what I have tried:</p>
  
  <pre><code>school_data_grouped = school_data_complete.groupby('school_name')
  passing_math_score = school_data_grouped.loc[(school_data_grouped['math_score'] &gt;= 70)]
  </code></pre>
  
  <p>I get an error with this that says:</p>
  
  <pre><code>AttributeError: Cannot access callable attribute 'loc' of 'DataFrameGroupBy' objects, try using the 'apply' method
  </code></pre>
  
  <p>What can I do to achive this? Any help is much appreciated.</p>
  
  <p>Thanks!</p>