Reputation: 1
Following the question and solution posted here:
I like to ask how to delete a row with a combined operator condition on a column value. In short, I like to delete all the rows whose 3rd column values are not between 7 and 15.
print (data[:,2])
to_remove = data[:,2] < 7 and data[:,2] >= 15
The above line is not allowed and it throws a value error.
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Upvotes: 0
Views: 81
Reputation: 1277
I think you need something like this :
result = []
for row in arr: # loop over the rows
if row[2] > 7 and row[2] < 15: # this is the condition you need
result.append(row) # store the rows which third column is between 7 and 15 in a new array
print(result)
Upvotes: 0