I am trying to rank some values in one column over a rolling period of N days instead of having the ranking done over the entire set. I have seen several methods here using rolling_apply but I have read that this is no longer in python. For example, in the following table;
| A | |
|---|---|
| 01-01-2013 | 100 |
| 02-01-2013 | 85 |
| 03-01-2013 | 110 |
| 04-01-2013 | 60 |
| 05-01-2013 | 20 |
| 06-01-2013 | 40 |
For the column A above, how can I have the rank as below for N = 3;
| A | Ranked_A | |
|---|---|---|
| 01-01-2013 | 100 | NaN |
| 02-01-2013 | 85 | Nan |
| 03-01-2013 | 110 | 1 |
| 04-01-2013 | 60 | 3 |
| 05-01-2013 | 20 | 3 |
| 06-01-2013 | 40 | 2 |