I have a pandas dataframe with a date column and a id column. I would like to return the number of occurences the the id of each line, in the past 14 days prior to the corresponding date of each line. That means, I would like to return "1, 2, 1, 2, 3, 4, 1". How can I do this? Performance is important since the dataframe has a len of 200,000 rows or so. Thanks !
| date | id |
|---|---|
| 2021-01-01 | 1 |
| 2021-01-04 | 1 |
| 2021-01-05 | 2 |
| 2021-01-06 | 2 |
| 2021-01-07 | 1 |
| 2021-01-08 | 1 |
| 2021-01-28 | 1 |