title: Subtracting unique id rows in pandas
body: <p><a href="https://i.stack.imgur.com/5EL1d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5EL1d.png" alt="output" /></a>I have a dataset like this, I need help with a code that will calculate difference for each id based on type a</p>
  <p>so for id 222, value for type a - type a, value for type b - type a, value for type c - type a.  and this will go for each unique IDs.</p>
  <pre><code>id   type   value   difference
  222   a      10.5
  222   b      70.0
  222   c      148.5
  333   a      40.5
  333   b      60.2
  333   c      180.5
  444   a      60.8
  444   b      140.2
  444   c      210.5
  </code></pre>