Using numpy.argmax() on multidimensional arrays

前端 未结 2 1355
孤街浪徒
孤街浪徒 2020-12-31 08:37

I have a 4 dimensional array, i.e., data.shape = (20,30,33,288). I am finding the index of the closest array to n using

index = abs(data - n).a         


        
相关标签:
2条回答
  • 2020-12-31 09:15

    You should be able to access the maximum values indexed by index using numpy.indices():

    x, z, t = numpy.indices(index.shape)
    data[x, index, z, t]
    
    0 讨论(0)
  • 2020-12-31 09:16

    If I understood you correctly, this should work:

    numpy.put(data, index, values)
    

    I learned something new today, thanks.

    0 讨论(0)
提交回复
热议问题