You do not even need to resort to numpy.argmax()in your example. Since your objects are in the standard Python list, you can also use the max()Python built-in function :
index = max(range(len(my_list)), key=lambda i: my_list[i].id)
or
index = max(enumerate(my_list), key=lambda x: x[1].id)[0]
will also give you the index of the item with the maximum id.
source
share