Rank each number by position in a list of arrays - Python

Viewed 160

I have a list of arrays and I want to rank the numbers against the similar positioned numbers in the other arrays in the list.

x = [[12,7,3],
    [4 ,5,6],
    [7 ,8,9]]

I tried the following and it ranked each numbers against all the numbers and also the smallest number is ranked 1

scipy.stats.rankdata(x)

array([ 9.,5.5,1.,2., 3.,4.,5.5,7.,8. ])

I want to rank with largest number ranked 1 and each number only ranked against the number that is in the same position in each array of the list.

This is the output that I need.

[[1,2,3]
[3,3,2],
[2,1,1]]
2 Answers
Related