Roma Karageorgievich - 1 year ago 224

Python Question

I have numpy array list:

`x = ["A", "A", "B", "A", "C", "D", "B"]`

For finding indexes of

`"A"`

`np.where(x == "A")`

How can I find indexes of

`"A"`

`"B"`

I used:

`np.where(x == ["A", "B"])`

np.where(x in ["A", "B"])

np.where(x == any(["A", "B"]))

But it didn't help me.

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

Answer Source

Use `|`

or `np_logical_or`

for element-wise OR:

```
x = np.array(x)
np.where((x=='A') | (x=='B'))
Out: (array([0, 1, 2, 3, 6], dtype=int64),)
np.where(np.logical_or(x=='A', x=='B'))
Out: (array([0, 1, 2, 3, 6], dtype=int64),)
```

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