I have a dataset with 4000 rows, where I have the duplicate rows(e.g. 2, 3, 4 times). I want to find the cumsum of the duplicates over time. I have used this code to assign the number of duplicity. But it has rearranged the position of ID Output whereas I want to add the duplicity and the ID remains same