I'm new to python/ programming. I'm trying to make a small function that loops through each row in an x-by-3 matrix have errors in them. I want to save all the rows without errors in a new x-by-3 matrix. For example, the input could be:
[[50. 0.096 2. ]
[15. 0.517 3. ]
[35. 1.086 4. ]
[40. 0.934 2. ]
[35. 0.109 1. ]]
My code:
def function(f5):
for i in range(f5.shape[0]):
if f5[i,0] < 10:
print("error1")
elif f5[i,0] > 60:
print("error2")
elif f5[i, 1] < 0:
print("error3")
elif (f5[i, 2] != 1) and (f5[i, 2] != 2) and (f5[i, 2] != 3) and (f5[i, 2] != 4):
print("error4")
else:
#I'm not sure how to save the rows that pass these tests in a
new matrix.
I would REALLY appreciate any help.