Index Error, Delete Row From Array If Column Has A Value
I have a array 'x' with four columns. For each row if the 4th column has a value of 1 then I want to delete that entire row: x = np.array([[1,2,3,0],[11,2,3,24],[1,22,3,1],[1,22,3,
Solution 1:
You're trying to reference the fourth column with [4], but since it's zero based it's actually [3]
Solution 2:
You can use indexing:
>>> x[x[:,3] != 1]
array([[ 1, 2, 3, 0],
[11, 2, 3, 24],
[ 5, 6, 7, 8]])
Post a Comment for "Index Error, Delete Row From Array If Column Has A Value"