I have a numpy recarray I want to find record where difference of 1st element and last element of record is maximum.
can someone suggest a way to do this.
I have a numpy recarray I want to find record where difference of 1st element and last element of record is maximum.
can someone suggest a way to do this.
Set up:
import numpy
ra = numpy.recarray((10,), 'int,int,int')
Find the index of the maximum of the difference between first field and last field.
idx = numpy.argmax(ra['f0']-ra['f2'])
Retrieve the record using that index
print ra[idx]