python - Deleting rows in numpy array between boundaries -
i have numpy array looks like:
a = np.array([1.2,10],[2.3,20],[3.4,30],[4.5,40],[5.8,50],[6.7,60],[7.8,70],[8.9,80]) now want check first column , delete thats smaller 3 , bigger 6. means want array like:
a = np.array([3.4,30],[4.5,40],[5.8,50]) the problem can't use np.delete() manually delete rows because dont know amount of rows.
do have iterate, or there simple way?
you don't want delete, want select. how can go it:
a = np.array([[1.2,10],[2.3,20],[3.4,30],[4.5,40],[5.8,50],[6.7,60],[7.8,70],[8.9,80]]) a[(a[:,0]>=3) & (a[:,0]<=6)] out: array([[ 3.4, 30. ], [ 4.5, 40. ], [ 5.8, 50. ]])
Comments
Post a Comment