I would like to re-enumerate a column of a pandas dataframe with repeated numbers. The column would look like the following:
df[col1] = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13]
The numerical values in the col1 are repeated 5 times each. What I am looking for is to re-numerate the values starting from 0, to look like the following:
df[col1] = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8]
Is there any functions or methods that I could use for this?
I have tried to create a new list with unique values in col1, then create a new list using the range method and try to map and replace the values from one list into the other list but it is not working. I would really appreciate any ideas on how to solve this issue. Thanks in advance.