Skip to content
Advertisement

Get the index of the largest two values per row

For each row, I would like to get the index of the largest two values.

JavaScript

Here’s the result I would like to obtain:

JavaScript

Advertisement

Answer

Use np.argsort along the second axis and take last two values reversed.

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