I have a numpy array consisting of 3 columns and there is one value in a column that has a negative value. I need to remove the whole row that contains this value as it corresponds to an anomalous result.
The numpy array looks a little like this:
[[98.4, 0.236, 0.0925]
[95.2, -0.162, 0.0625]
[92.3, 0.112, 0.0526]]
How would I go about removing the whole row that contains the negative value?
CodePudding user response:
You can index with a boolean mask:
result = array[(array >= 0).all(axis=1)]