How to turn a boolean array into index array in numpy

前端 未结 4 972
执念已碎
执念已碎 2020-12-23 19:07

Is there an efficient Numpy mechanism to retrieve the integer indexes of locations in an array based on a condition is true as opposed to the Boolean mask array?

For

4条回答
  •  天涯浪人
    2020-12-23 19:31

    If you prefer the indexer way, you can convert your boolean list to numpy array:

    print x[nd.array(mask)]
    

提交回复
热议问题