I have a panda dataframe df below;
pay pay2 date
0 209.070007 208.000000 2018-08-06
1 207.110001 209.320007 2018-08-07
2 207.250000 206.050003 2018-08-08
3 208.880005 207.279999 2018-08-09
Given a last_date, I want to retrieve the past n rows from last_date onwards, including the row of last_date itself.
For instance, given last_date = '2018-08-08' and n=3. The result dataframe should look like this;
pay pay2 date
0 209.070007 208.000000 2018-08-06
1 207.110001 209.320007 2018-08-07
2 207.250000 206.050003 2018-08-08