Skip to content
Advertisement

Pandas get rank on rolling with FixedForwardWindowIndexer

I am using Pandas 1.51 and I’m trying to get the rank of each row in a dataframe in a rolling window that looks ahead by employing FixedForwardWindowIndexer. But I can’t make sense of the results. My code:

JavaScript

results:

JavaScript

By my reckoning, it should look like:

JavaScript

I am basing this on a backward-looking window, which works fine:

JavaScript

Any assistance is most welcome.

Advertisement

Answer

Here is another way to do it:

JavaScript

Then:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement