0

I have a data set that looks like this

Stock Number    Date completed  Username    Team
  694009        01/10/2019         4       RS PRO
  1368299       01/10/2019        18       II&T
  1774499       01/10/2019         4       RS PRO
  1774504       01/10/2019         4       RS PRO
  1774505

I want to add up as it goes down the column, so we can see the 'Username' column. How can I code so every time it sees the same number add one? We can see Username '4' there. I want to see:

 Username  Count
   4        1
   4        2
   4        3
   4        4
   4        5 
   4        6

thanks

gazza81288
  • 11
  • 3
  • 1
    `df['Count'] = df.groupby('Username')['Username'].cumcount()`, this is a duplicate, just cant find it. – Erfan Jan 14 '20 at 16:50
  • In the future, make it so that the expected output matches with the input. User 4 has the wrong number of rows and 18 just disappeared.It will help people answer your question and it will be much clearer to anyone who stumbles upon this in the future when you likely won't be around to comment and clarify points. – ALollz Jan 14 '20 at 16:51

0 Answers0