I have a numpy array a: [True, False, True, False, False, ...] And I like to have a numpy array that has the indices of the True and False values, i.e. [0, 2, ...] and [1, 3, 4, ...]
To get the indices of the True values in a, you can use
a.nonzero()
For the indices of the False values, use
(~a).nonzero()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With