1

I have two arrays

c = [ [1, 2, 3],
      [3, 7, 8],
      [5, 2, 4] ]

and

u = [ [3, 7, 8],
      [1, 3, 2],
      [1, 3, 7] ]

I want to find the maximum of c for each row, and the corresponding value in u. That would be:

cMax = [3, 8, 5]

and

uMax = [8, 2, 1]

I have tried

cMax = np.nanmax(c, axis=1)
cMaxIdx = np.argmax(c, axis=1)

which gives

cMax = [3, 8, 5]
cMaxIdx = [2, 2, 0]

and

uCMax = u[:,cMaxIdx]

which gives

uCMax = [ [8, 8, 3]
          [2, 2, 1]
          [7, 7, 1] ]
acb
  • 177
  • 2
  • 10

0 Answers0