r = np.array([[0.89771084, 0.84415435, 0.81601728, 0.42322215, 0.78240944],
    [0.84490939, 0.53644975, 0.3506268, 0.98212093, 0.76426087], [0.254155,
    0.12818165, 0.82656036, 0.97441244, 0.58597015], [0.50566688, 
    0.67774518, 0.58434845, 0.5204808, 0.9225643], [0.73930611, 0.31890204,
    0.47691016, 0.28034347, 0.57832287]])
col_order = np.argsort(r, axis=0)[::-1, :]
row_order = np.argsort(r, axis=1)[:, ::-1]
col_rank = np.argsort(col_order, axis=0)
row_rank = np.argsort(row_order, axis=1)
n = 2
col_top_n = col_rank < n
row_top_n = row_rank < n
both_top_n = np.logical_and(row_top_n, col_top_n)
row_indices, col_indices = np.nonzero(both_top_n)
print('The following elements are in the top {} of both their rows and columns:'.format(
    n))
for row, column in zip(row_indices, col_indices):
    pass
Как найти расположение элементов в массиве numpy