Pandas Label Duplicates
<p>Given the following data frame:</p>

<pre><code>import pandas as pd
d=pd.DataFrame({'label':[1,2,2,2,3,4,4],
               'values':[3,5,7,2,5,8,3]})
d
    label   values
0     1       3
1     2       5
2     2       7
3     2       2
4     3       5
5     4       8
6     4       3
</code></pre>

<p>I know how to count the unique values like this:</p>

<pre><code>d['dup']=d.groupby('label')['label'].transform('count')
</code></pre>

<p>Which results in:</p>

<pre><code>    label   values  dup
0     1     3       1
1     2     5       3
2     2     7       3
3     2     2       3
4     3     5       1
5     4     8       2
6     4     3       2
</code></pre>

<p>But what I would like is a column to have the following values:
<code>1</code> if there is <code>1 unique</code> row per the label column, <code>2</code> if there are <code>duplicates</code> and the row in question is the <code>first</code> of such, and <code>0</code> if the row is a <code>duplicate</code> of an original. Like this:</p>

<pre><code>    label   values  dup  status
0     1     3       1     1
1     2     5       3     2
2     2     7       3     0
3     2     2       3     0
4     3     5       1     1
5     4     8       2     2
6     4     3       2     0
</code></pre>

<p>Thanks in advance!</p>