Skip to content
Advertisement

Why the rank function is not working when I set axis=1?

I have this code:

JavaScript

The code is working as it is but is not returning What I want. I was trying to rank num considering only it’s row so

JavaScript

I tried to change this line:

JavaScript

to:

JavaScript

But it didn’t work.

What am i missing here?

Advertisement

Answer

Building on what you already have here:

JavaScript

we could add the Rank column as follows. The idea is to compare the num column with the quantile columns and get the first column name where the quantile value is greater than a num value. As it happens each quantile column already has rank numbers on it, so we use those to assign values:

JavaScript

Output:

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