2

Is there a convenient way to delete a row containing some value in a recarray? Say I have the following array,

a=numpy.array([(1.0, 2.0, 3.0), (4.0, 5.0, 10.0),(1.0,10.0,4.0)], 
dtype=[('A', '<f8'), ('B', '<f8'), ('C', '<f8')])

And I wanted to remove all rows with 10 in the B column so that the output is

([(1.0, 2.0, 3.0), (4.0, 5.0, 10.0)], 
dtype=[('A', '<f8'), ('B', '<f8'), ('C', '<f8')])

Is there a quick way to do this?

4

1 回答 1

3

Just pull out the relevant rows of the original array:

new_a = a[a["B"]!=10.0]
于 2014-05-30T21:45:03.313 回答