Question
Is there a way using numpy to sort maximum of range of previous x numbers?
Example
Array of [1, 3, 4, 2, 6, 7, 8, 8, 2, 3], and the range is 3
The output should be [nan, nan, nan, 4, 4, 6, 7, 8, 8, 8].
The first three elements has no 3 previous numbers, so the result is nan.
The fourth elements (2) has the previous numbers of 1, 3, 4, therefore the max is 4.
Sorry for the misleading.
I will provide a second example.
Original array: [1, 3, 4, 6, 2, 8, 2, 3, 1, 2]
Output: [nan, nan, nan, 4, 6, 6, 8, 8, 8, 3]
For the last element of output: 3, the reason in the 7th, 8th and 9th elements in original array are 2, 3, 1, therefore the max is 3.
Thanks!