I have a data frame that looks like the table below that keeps track of a person visiting a store in a certain month. I want to create a new column, Total_Visits, that is a count of the number of times a certain ID visited the store during a certain month. In the below example, for date 6-13 and ID 23, the Total_Visits would have 3 in any row where date == 6-13, and ID == 23.
Date ID
6-13 23
6-13 34
6-13 23
6-13 23
7-13 23
Data frame I'm looking for would be
Date ID Total_Visits
6-13 23 3
6-13 34 1
6-13 23 3
6-13 23 3
7-13 23 1
While I assume there is some sort of acast function to ensure that I don't have to loop through this (30,000 rows), I would be OK with a loop if vectorization did not work.