I'm looking to count the number of occurrences in a column, based on a certain time delta. Consider the following dataset example:
Date Type
0 2016-04-01 A
1 2016-04-01 A
2 2016-04-02 A
3 2016-04-02 B
4 2016-04-03 C
5 2016-04-04 B
6 2016-04-05 C
7 2016-04-06 C
8 2016-04-06 A
I want to create a column that contains how often the same type has been registered in for example the last two days, e.g:
Date Type N_Occs_Last_2_Days
0 2016-04-01 A 1
1 2016-04-01 A 2
2 2016-04-02 A 3
3 2016-04-02 B 1
4 2016-04-03 C 1
5 2016-04-04 B 1
6 2016-04-05 C 1
7 2016-04-06 C 2
8 2016-04-06 A 1
I've found some information on a similar problem: how to extract the average value, but I have a hard time in extracting the counts. Can anyone point me in the right direction?