My dataframe is like this:

```
a      b
0      123
0      321
0      456
12345  1234
43241  132
0      2134
12345  6543
43241  987
....

```

I need to set values in the third column according to a list (edit: `a` is not necessarily ordered):

```
a     0     12345 43241 ....
c     0     1     2     ....

```

so it should become

```
a      b     c
0      123   0
0      321   0
0      456   0
12345  1234  1
43241  132   2
0      2134  0
12345  6543  1
43241  987   2
....

```

Currently I'm doing this in a cycle:

```
a=data['a'].unique().tolist()
c=list(range(len(a)))
d=dict(zip(c,a))
df['c']=0
for i in d:
    df.loc[df['a']==d[i],'c']=i

```

Is there a simpler way to do it?