title: Perform calculation for different group python pandas
body: <p>I have a pandas data set with different groups. For each group, I want to apply different calculations. What's the best way to do it?</p>
  <p>For example,</p>
  <p>Input data</p>
  <pre><code>Group val1 val2
  1      12   3
  1      19   4
  2      23   9
  3      59   74
  3      2    44
  </code></pre>
  <p>Output data</p>
  <pre><code>Group val1 val2 output
  1      12   3   3*val1*val2
  1      19   4   3*val1*val2
  2      23   9   5*val1*val2
  3      59   74  10*val1*val2
  3      2    44  10*val1*val2
  </code></pre>