Python value difference in dataframe by group key
<p>I have a DataFrame </p>

<pre><code>name   value
A       2
A       4
A       5
A       7
A       8
B       3
B       4
B       8
C       1
C       3
C       5 
</code></pre>

<p>And I want to get the value differences based on each name
like this </p>

<pre><code>name   value   dif
A       2      0
A       4      2
A       5      1
A       7      2
A       8      1
B       3      0
B       4      1
B       8      4
C       1      0
C       3      2
C       5      2
</code></pre>

<p>Can anyone show me the easiest way?</p>