0

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
user424060
  • 1,545
  • 3
  • 20
  • 29

1 Answers1

2

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]
Paul
  • 42,322
  • 15
  • 106
  • 123