Mati Malik - 2 years ago 130

Python Question

I have this array

`scale=np.array([-3,0,2,4,7,10,12])`

And this matrix

`matrix=np.array([[17, 10, 10],`

[10, 12, 12],

[ 7, 7, 4],

[-3, 11, 2]])

Now i want to know the indices of the rows in matrix which doesn't contain any of the elements in scale. The output should be:

`array([0,3])`

I've tried with np.where, np.all and np.any without solving the problem.

Do you have a simple solution to this?

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

You are rather looking for:

```
np.where(~np.in1d(matrix, scale).reshape(matrix.shape).all(axis=1))
#(array([0, 3], dtype=int64),)
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**