There is a column in my dataset that looks like that:
col1
100
100
100
101
101
102
102
103
103
103
103
104
104
I want to create a column that gives an increasing number per group. Specifically, where is 100 in the col1 there will be 01. The next 100 will have 02 and so on. When it reaches to the row that has 101 it will perform similarly:01, the next 101, 02 like it did with 100.
I tried it and I can't make it do what I am planning: I have to make a new column first
df['nc'] = df.groupby(col1)
which is wrong.
Desired output:
col1 nc
100 01
100 02
100 03
101 01
101 02
102 01
102 02
103 01
103 02
103 ........ and so on
103
104
104