I am trying to add a numeric key to my dataframe, but I want the number to correspond to the value in a specific column. This column has repeats, and I would like the numeric key to reflect that.
For example, this is a generalized look at my dataframe:
Gene Type
A 1
A 2
B 1
C 1
C 1
C 2
I'm leaving a lot out of the table for simplicity's sake. I would then like the numeric key to reflect the value of the Gene column, so that it looks like this:
Gene Type Key
A 1 1
A 2 1
B 1 2
C 1 3
C 1 3
C 2 3
Any suggestions? I've hit a mental block and really have no idea what to do.