title: Python Dataframe: Calculating R^2 and RMSE Using Groupby on One Column
body: <p>I have the following Python dataframe: </p>
  
  <pre><code>Type    Actual  Predicted
  A       4       3
  A       10      18
  A       13      11
  B       3       10
  B       4       2
  B       8       33
  C       20      17
  C       40      33
  C       87      80
  C       32      30
  </code></pre>
  
  <p>I have the code to calculate R^2 and RMSE but I don't know how to calculate it by distinct "Type".  </p>
  
  <p>For now, my methodology is breaking the larger table into three smaller tables consisting of only A, B, C values and then calculating R^2 and RMSE off each smaller table...then appending them back together.  </p>
  
  <p>But the above method is inefficient and I believe there should be an easier way?  </p>
  
  <p>Below is the format I want the results to produce when things are grouped:   </p>
  
  <pre><code>Type    R^2     RMSE    
  A       value   value   
  B       value   value   
  C       value   value   
  </code></pre>