Skip to content
Advertisement

Getting the minimum indexes with numpy Python

I am trying to get the index values of the function. But I want to get the minimum instead of the maximum values of just like the post: post. I have tried to convert the function below to work for the minimum values unlike the maximum values to getting the indexes.

Max Values:

JavaScript

Index Function

JavaScript

Advertisement

Answer

For the minimum, you need the first item in each group rather than the last. This is accomplished by modifying grp_shifted_argmin:

JavaScript

This correctly returns the index of the minimum value within each sublist:

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