我有一个numpy数组a:[True,False,True,False,False,...]我喜欢有一个numpy数组,其索引为True和False值,即[0,2,... ]和[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()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.