I have the following dataframe, each row represent a sale transaction:
startDate INDEX_250 priceDeal
2013-05-02 00:00:00 9312.000 255000.000
2013-09-17 00:00:00 11121.000 368209.000
2013-10-09 00:00:00 11121.000 254000.000
2013-11-14 00:00:00 11121.000 520000.000
2013-11-22 00:00:00 11121.000 201000.000
2014-02-05 00:00:00 11121.000 260000.000
2014-02-28 00:00:00 11121.000 425000.000
2014-03-01 00:00:00 11121.000 315000.000
2014-03-11 00:00:00 9312.000 427000.000
2014-04-27 00:00:00 9312.000 138070.000
2014-06-20 00:00:00 9312.000 270000.000
2014-07-21 00:00:00 9312.000 282000.000
2014-07-31 00:00:00 9312.000 308806.350
2014-09-27 00:00:00 11121.000 170000.000
2014-10-05 00:00:00 11121.000 171658.220
2014-10-11 00:00:00 11121.000 292000.000
2014-10-13 00:00:00 11121.000 125000.000
2014-10-30 00:00:00 9312.000 95000.000
2014-11-18 00:00:00 9312.000 158942.280
2015-01-25 22:00:00 11121.000 238829.370
2015-03-11 00:00:00 11121.000 180695.960
2015-03-14 00:00:00 9312.000 320932.860
2015-03-21 00:00:00 11121.000 139872.000
2015-09-04 00:00:00 11121.000 140000.000
2015-09-09 00:00:00 9312.000 235000.000
i want to see how many sales transactions happened in previous 30 day nrTargets_gr_250_30 and 60 day nrTargets_gr_250_60 for each (grouped by) INDEX_250 from the first sale transaction 2013-09-17. example dataset is only for one INDEX_250 but there are other index numbers as well, following out put is desirable:
startDate INDEX_250 nrTargets_gr_250_30 nrTargets_gr_250_60
2013-10-17 11121 2.000 2.000
2013-11-16 11121 1.000 3.000
2013-12-16 11121 1.000 2.000
2014-01-15 11121 0.000 1.000
2014-02-14 11121 1.000 1.000
2014-03-16 11121 2.000 3.000
2014-04-15 11121 0.000 2.000
2014-10-12 11121 3.000 3.000
2014-11-11 11121 1.000 4.000
2014-12-11 11121 0.000 1.000
2015-02-09 11121 1.000 1.000
2015-03-11 11121 0.000 1.000
2015-04-10 11121 2.000 2.000
2015-05-10 11121 0.000 2.000
2015-09-07 11121 1.000 1.000
2015-10-07 11121 0.000 1.000
2016-02-04 11121 1.000 1.000
2016-03-05 11121 0.000 1.000
2017-01-29 11121 1.000 1.000